Hi,
I am having a file which is fix length and comma seperated. And I want to replace values for one column.
I am reading file line by line in variable $LINE and then replacing the string.
Problem is after changing value and writing new file temp5.txt, formating of original file is getting lost. It is removing all the blank spaces.
Sample value: Original File
LINE="000001077,03190, , 1 Main Street, , , , Foxboro , 02035,1,MA,12-13-2010 22:43:42,12-13-2010 22:43:42"
I want to replace MA with 00021
I am reading file line by line in variable $LINE and then replacing the string
echo $LINE | sed "s/",MA,"/",00021,"/g" >>temp5.txt
temp5.txt:
000001077,03190, , 1 Main Street, , , , Foxboro , 02035,1,00021,12-13-2010 22:43:42,12-13-2010 22:43:42
Please help.
Thanks