Fix typo
[project-aon.git] / common / scripts / list-bookcodes-by-lang.sh
1 #!/usr/bin/env bash
2 #
3 # List all bookcodes that match given language.
4
5 # Example:
6 #     list-bookcodes-by-lang.sh en es
7
8 if [ ! -d "$AONDIR" ]; then
9     >&2 echo "Please set the AONDIR environment variable"
10     exit 1
11 fi
12
13 book_db="$AONDIR/common/sqlite/bookcodes.db"
14
15 for lang in $@
16 do
17     if [[ ! $lang =~ ^[a-z][a-z]$ ]]; then
18         >&2 echo "invalid language"
19         exit 1
20     fi
21
22     sqlite3 -noheader "$book_db" <<EOF
23       select book 
24       from bookcodes 
25       where lang = '$lang'
26       order by book
27 EOF
28 done