Home » Infrastructure » Unix » REFORMATING FILE
icon5.gif  REFORMATING FILE [message #299638] Tue, 12 February 2008 16:06 Go to next message
kham2k
Messages: 34
Registered: May 2007
Member
Hi All
I am trying to reformat a flat file but im facing a issue
let me explain myself
Orignal File:
010800650022000003190000000+000002ECLPSE BIG E SPEAR000022505                   ^M
010800650034000003470000000+000006YORK MINT TIN     000012405                   ^M
010800650012546310530000000+000003DENTYNE ICE GUM   000022005                   ^M
010800650012546310510000000+000001DENTYNE ICE GUM   000022005                   ^M
010800650034000003470000000+000006YORK MINT TIN     000012405                   ^M


but when i run a reformat script im losing all the spaces, which i need;
script is as following:
cat file | while read line
do
  echo "20084\c" >> newFile.dat
  echo $line >> newFile.dat

done

20084010800650022000003190000000+000002ECLPSE BIG E SPEAR000022505 ^M
20084010800650034000003470000000+000006YORK MINT TIN 000012405 ^M
20084010800650012546310530000000+000003DENTYNE ICE GUM 000022005 ^M
20084010800650012546310510000000+000001DENTYNE ICE GUM 000022005 ^M
20084010800650034000003470000000+000006YORK MINT TIN 000012405 ^M

I have tried it with print as well but no luck so far.
I would like to keep the format as the original file.

Thanks for your help in advance

Laters
Re: REFORMATING FILE [message #299646 is a reply to message #299638] Tue, 12 February 2008 17:56 Go to previous message
kham2k
Messages: 34
Registered: May 2007
Member
I found out this works fine

just replce
echo $line >> newFile.data
with this
echo "$line" >> newFile.dat

[Updated on: Tue, 12 February 2008 17:57]

Report message to a moderator

Previous Topic: Creating a report by running an SQL script from shell script
Next Topic: Changing First line in existing Flat file
Goto Forum:
  


Current Time: Thu Mar 28 07:37:19 CDT 2024