I am VERY new to unix scripting. I am having trouble parsing a line into fields for further processing.
I have this script:
#bin/sh
cat ztest2.txt | while read line
do
zvar1=`echo $line | cut -f6`
echo "zvar1 is " $zvar1
done
********************
ztest2.txt looks like:
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 9
3 4 5 6 7 8 9 10
4 5 6 7 8 9 10 11
where the spaces in between the numbers are tabs.
the output of this script is:
zvar1 is 1 2 3 4 5 6 7 8
zvar1 is 2 3 4 5 6 7 8 9
zvar1 is 3 4 5 6 7 8 9 10
zvar1 is 4 5 6 7 8 9 10 11
if i just run from the command line:
cut -f6 ztest2.txt
i get
6
7
8
9
Can anyone help.