Hi,
I got it working like this :
if [ -n "`tail -1c $file`" ]
then
echo >> $file
fi
This wil append new-line at the EOF if it does not exists.
I have some more file-level validation to take care. Need your valuable inputs on this.
My (comma-separated) file is something like below:
1.0,20080317081500,00001,00006,6
00001,20080317,00001,60213000071,2105,I
00002,20080317,00002,60213000071,0,D
00003,20080317,00003,60213000072,2104,I
00004,20080317,00004,60213000073,2103,I
00005,20080317,00005,60213000074,2102,I
00006,20080317,00006,60213000074,0,D
10.1.254.21
Ignoring first line and last line, I need to retrieve the last 3 fields of the other lines, for further validation. Copying these fields, to a separate file also is ok.
The new file can be:
60213000071,2105,I
60213000071,0,D
60213000072,2104,I
60213000073,2103,I
60213000074,2102,I
60213000074,0,D
Here i need to validate 2 points:
1. In each line, first field should have length equal to 11 and start with 60
2. In each line, last field should have either "D", "I" or "U" in it.
Pls let me know about this.
With Regards,
Krishna