Hi,
I want to get the second field from a file (report.txt)like this:
$ cat report.txt
SheetName|RecordName|FieldName|TableName|ColumnName|Change
Summary||2||No specification received for output file record|MODIFIED
Central Checks|R3002SPLDXVOLUME|F3002-VOL1-VOL-SRL-NUM|SUBMISSION|SERIAL_NUM|DEL
ETED
Suspense data|RC3310SUSPMIGXDATA||||ADDED
Suspense data|RC3310SUSPMIGXDATA|FC3310-RECORD-TYPE|||ADDED
I am using while loop to get the fourth field.but it is giving error like this:
5
Summary||2||No specification received for output file record|MODIFIED
./example.sh: syntax error at line 12: `end of file' unexpected
I am getting the line count and using the line count in while loop how to go through the file and get the fourth field from the file.
My code is as follows:
#!/bin/sh
nooflines=`wc -l report.txt| sed -e "s/[a-zA-Z. ]*//g" `
echo $nooflines
i=2
echo `awk -F"|" 'NR==2 {print $4}' report.txt`
while [ $i -le $nooflines ]
do
echo `awk -F"|" `NR==$i {print $4}' report.txt`
echo $i
i=`expr $i + 1`
done
Thank you.
Roopa.A