diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-02-25 23:46:10 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-02-25 23:46:10 -0500 |
| commit | e7224c7696ec23ed62b198f16f5f3d597daac9e2 (patch) | |
| tree | 3bcae4313a88f951887950c559eaf5b556603289 /oeb.sh | |
| parent | 51c72d562be42fd7748192bfd87d7acfe1ac34a6 (diff) | |
| download | cgi-bin-e7224c7696ec23ed62b198f16f5f3d597daac9e2.tar.gz | |
oeb: parse scripref in shell
Diffstat (limited to 'oeb.sh')
| -rwxr-xr-x | oeb.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/oeb.sh b/oeb.sh index 15c298a..83568e1 100755 --- a/oeb.sh +++ b/oeb.sh @@ -1,10 +1,15 @@ #!/bin/sh # parse query -book=John -chstart=3 -chend=3 -vstart=16 -vend=17 +test "$QUERY_STRING" || QUERY_STRING="$1" +book=$(echo $QUERY_STRING|cut -d' ' -f1) +chstart=$(echo $QUERY_STRING|tr ':' ' ' |cut -d' ' -f2) +vstart=$(echo $QUERY_STRING|tr '-' ':' | cut -d: -f2) +# vend is always the last number +vend=$(echo $QUERY_STRING |tr - : |rev|cut -d: -f1|rev) +# chend is the last leftover +chend=$(echo $QUERY_STRING|sed "s/$book //"| sed "s/:$vstart-/ /"|sed "s/ \?:\?$vend$//"|rev|cut -d' ' -f1|rev) +#echo $chstart "\t" $vstart "\t" $chend "\t"$vend && exit + file=$(find oeb/ -name '*'-$book'*') grep '\c '$chstart $file -A500 | grep '\v '$vstart -A500 \ | grep '\c '$(($chend + 1)) -B500 | grep '\v '$vend -B500 |
