scripts for my gemini capsule
oeb: parse scripref in shell
| -rwxr-xr-x | oeb.sh | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 |