Hi,
I have a CSV file with footer information as below. The third value is the number of records in the file. Sometimes it contains both leading and trailing white spaces which i want to trim using awk.
C,FOOTER , 00000642
C,FOOTER , 00000707
C, FOOTER, 42
C, FOOTER, 129
eval `awk -F, ' /FOOTER/ {print "set RecordsFound=" $3}
/HEADER/ { print "set FileBusinessDate=" $4} END{ print "set ActualRecords=" NR-2 } ' ${SourceDir}/${FileCsv} `
Above is the command which is already present in production and this statement fails since the $3 has spaces in it. So far we didn't get any spaces in the CSV, so this statement was working fine for the past 1 year.
Is there any way to trim the spaces(both leading and trailing spaces) in AWK?
I tried gsub(/ /,"",$3) but it doesn't work
Any help is much appreciated
Thanks in Advance
Mohana