I am trying to create files using AWK with in a for loop but getting empty file. It looks like AWK is not getting executed. Can you please advise, what is incorrect here?
I have a file $LOG/order_"$id".txt which has some lines between 2 strings CUT:1 and CUT2 etc.. I just need these lines in separate files so I wrote this for loop.
for (( i=1; i<=$CNTLN; i++ ))
do
j=`expr $i - 1`
/usr/bin/awk '/CUT:$j/, /CUT:$i/' $LOG/order_"$id".txt > $LOG/order_"$id"_"$i".txt
done
This generate blank file however if I copy and past this command on shell, it works.
Please advise.