Add rule regarding safekeeping of special objects in Kai Monastery. Harmonise translation
[project-aon.git] / common / scripts / list-bookcodes-by-series.sh
1 #!/usr/bin/env bash
2 #
3 # List all bookcodes that match given series.
4
5 # Example:
6 #     list-bookcodes-by-series.sh lw gs
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 series in $@
16 do
17     if [[ ! $series =~ ^[a-z]+$ ]]; then
18         >&2 echo "invalid series"
19         exit 1
20     fi
21
22     sqlite3 -noheader "$book_db" <<EOF
23       select book 
24       from bookcodes 
25       where series = '$series'
26       order by book
27 EOF
28 done