Thanks for helping thick headed people like me.
I have a line in a script that works fine in gawk but fresh installs of debian based systems come with mawk instead. On a desktop or laptop that is not an issue really because storage space and cpu power are plentiful. But I wish to use this script on a Pi where storage space and cpu power are in limited supply.
So I would like to change this line to work with mawk, and gawk if possible.
Code:
BLOCKHEAD=$(awk "/\y${data[1]}\y/ {print FNR}" $TMPDIR/tempfile1b)
It fails with this output
Code:
+ w3m -dump -T text/html /home/kingbee/bin/shabbat/data/JPS/et0125.htm
+ sed 1,5d
+ sed -e :a -e '$d;N;2,6ba' -e 'P;D'
+ (( 19 > 1 ))
++ awk '/\y19\y/ {print FNR}' /home/kingbee/bin/shabbat/tmp/tempfile1b
+ BLOCKHEAD=
+ BLOCKHEAD=-1
+ sed -i '1,-1 d' /home/kingbee/bin/shabbat/tmp/tempfile1b
sed: -e expression #1, char 3: unexpected `,'
++ sed -n -e '1 s/^.*19/19/p' /home/kingbee/bin/shabbat/tmp/tempfile1b
+ FIRSTLINE=
With gawk it outputs
Code:
+ w3m -dump -T text/html /home/rbees/bin/shabbat/data/JPS/et0125.htm
+ sed 1,5d
+ sed -e :a -e '$d;N;2,6ba' -e 'P;D'
+ (( 19 > 1 ))
++ awk '/\y19\y/ {print FNR}' /home/rbees/bin/shabbat/tmp/tempfile1b
+ BLOCKHEAD=31
+ BLOCKHEAD=30
+ sed -i '1,30 d' /home/rbees/bin/shabbat/tmp/tempfile1b
++ sed -n -e '1 s/^.*19/19/p' /home/rbees/bin/shabbat/tmp/tempfile1b
+ FIRSTLINE='19 And these are the generations of Isaac, Abraham'\''s son: Abraham begot Isaac. '
+ sed -i '1s/.*/19 And these are the generations of Isaac, Abraham'\''s son: Abraham begot Isaac. /' /home/rbees/bin/shabbat/tmp/tempfile1b
mawk on pi mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
gawk on Desktop GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2016 Free Software Foundation.
From what I have read if the versions of mawk and gawk are the same then they are compatible but clearly my versions are not the same.
The desktop is running Wheezy (stable) the pi is running raspbian wheezy.
So is it doable or should I just install gawk?
Note: there are other lines in the script that may fail when conditions hit them but at this point I am not aware of them.
Thanks again for your time.