"read line" ignoring last line
Hi All,
I am facing a wierd problem. I have about a 100 shell scripts all coded
in a similar fashion. All of them read from some file(s) and process
the data.
But there is this one script which reads from a small file which has
only 2 lines of data. What happens (and happens only for this script)
is that only the first line is read, and the last line is ignored
completely. I do not get any errors.
What we do to workaround this problem is to just open the file (vi)..
add a new line to the end and just remove that line. Then when we run
the same script it works. But we do not want to keep doing that.
Here is my rather simple script:
************************************************** ***
cat ./data/BACSTEL_APPLICATION_DATA.txt | while IFS= read line
do
echo $line
done
************************************************** ***
And here is the data file:
************************************************** ***
$ more data/BACSTEL_APPLICATION_DATA.txt
BACSTEL~account type~Business User~~0~
BACSTEL~account type~Admin User~~0~
************************************************** ***
When I run the script. This is the output:
************************************************** ***
$ ./populate_bacstel.ksh
BACSTEL~account type~Business User~~0~
************************************************** ***
All other scripts are coded in a very similar fashion... they all run
fine, except this. Can it be that this is too small a file .....?? Coz
that is the only diff.. the next shortest data file is 4 lines long....
but that is soo wierd!
Thanks,
Anoop
|