I need some help regarding in writing a Korne shell script, in determining the fixed length records in a data file. We have already utility in place, which does this work. The Code for this is as below. In the below $1 is the parameter passed to the script, which is the data file name.
This script is working for the files which is having characters less than or equal to 10239.
But this script fails for the lengthy data files, where the characters in the file exceeds 10239.
I have got 3 files, which have characters exceeding 13,000 and less than 16,000.
Can anyone let me know, as how to overcome this problem.
======================================================
CHKLEN=`awk 'NR==1 {print length($0)}' $1`
if [ "$CHKLEN" != "" ]
then
awk "length != $CHKLEN { exit 1 }" $1
if [ $? -ne 0 ]
then
return 1
fi
# Add one for CRLF
let CHKLEN=CHKLEN+1
echo $CHKLEN
else
echo 0
fi
return 0
HI,
AWK has a limitation of the length of records.
That is if a single line exceeds certain length, (I think its 1400 if i am not wrong) then it will throw an error.
Check the version of AWK and if possible get a newer version of it.
Better try using perl which is best suited for this.