I use while do - done loop in my shell script. It is working as per my expectations.
But I do not want to process all the lines. I am finding it difficult to exclude certain lines.
1) I do not want to process blank lines as well as lines those start with a space " "
2) I do not want to process the headings. The headlines start with the word AGENT or PRODUCT or TOTAL
I think the following KornShell script can do the job
#!/bin/ksh
IFS='
'
while read LINE
do
for TOKEN in $LINE
do
UPPER=$(print $TOKEN | tr '[a-z]' '[A-Z]')
if [[ ($UPPER = +([ ])*) ||
($UPPER = *([ ])+(TOTAL|AGENT|PRODUCT)*) ]]
then
continue
else
# And here you put all
# instructions to process the input
# don't forget the following break
break
fi
done
done < $1
Actually, because here you ignore also the space character, you will need to modify the default IFS. In fact, the space characters (and I suppose the tabs) must be omitted. The IFS containing only the new line character is defined in the following way
IFS='
'
If you just write something like $'\n' or "\n" it doesn't work. The same is true about tabs. If you want to define a pattern including one or several space/tab characters you have to write [ ], that is, after [ you put a space character and then you push the tab key before closing ] (if instead of doing that you write \t it will not work)