Home » Infrastructure » Unix » REFORMATING FILE
icon5.gif  REFORMATING FILE [message #299638] Tue, 12 February 2008 16:06 Go to next message
Messages: 34
Registered: May 2007
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
  echo "20084\c" >> newFile.dat
  echo $line >> newFile.dat


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

Re: REFORMATING FILE [message #299646 is a reply to message #299638] Tue, 12 February 2008 17:56 Go to previous message
Messages: 34
Registered: May 2007
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: Wed Aug 16 12:36:07 CDT 2017

Total time taken to generate the page: 0.07004 seconds