From e7224c7696ec23ed62b198f16f5f3d597daac9e2 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Thu, 25 Feb 2021 23:46:10 -0500 Subject: oeb: parse scripref in shell --- oeb.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'oeb.sh') 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 -- cgit 1.4.1