I'm writing a script in bash and basically I want to read certain lines from html files that start with a date. I want these lines in an array (X). I use this awk command, but for some reason it won't execute properly from within the script.
Code:
declare -a TITLES
ArrayCounter=0
LineCounter=1
while [ $LineCounter -le ${#CNNUMMERS} ]; do
# commando="grep -o -E ^$Day.*$Year[.].* $FILE_TEMP | awk 'NR == $LineCounter {print}' -"
commando="awk -F\<br\>\<br\> '/$Day.*$Year/ {print \$1}' $FILE_TEMP | awk 'NR == $LineCounter {print}'"
echo Loop is running for the $LineCounter th time.
echo The command is $commando
TITLES[$ArrayCounter]=`$commando`
echo We already added $LineCounter titles to the array: ${TITLES[$ArrayCounter]}
((ArrayCounter=$ArrayCounter+1))
((LineCounter=$LineCounter+1))
done
This is the output:
Code:
Loop is running for the 1 th time.
The command is awk -F\<br\>\<br\> '/30.*1994/ {print $1}' /tmp/tmpscript | awk 'NR == 1 {print}'
awk: syntax error at source line 1
context is
>>> ' <<<
awk: bailing out at source line 1
We already added 1 titles to the array:
Loop is running for the 2 th time.
The command is awk -F\<br\>\<br\> '/30.*1994/ {print $1}' /tmp/tmpscript | awk 'NR == 2 {print}'
awk: syntax error at source line 1
context is
>>> ' <<<
awk: bailing out at source line 1
We already added 2 titles to the array:
Loop is running for the 3 th time.
The command is awk -F\<br\>\<br\> '/30.*1994/ {print $1}' /tmp/tmpscript | awk 'NR == 3 {print}'
awk: syntax error at source line 1
context is
>>> ' <<<
awk: bailing out at source line 1
We already added 3 titles to the array:
If I copy paste the command echo'd in the output, It runs as it's supposed to run though :s
I'm running the script on an old Apple PowerBook, OS X Leopard, Darwin 9.8.0
tia for any help!