Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Data in a File 2

Status
Not open for further replies.

pavithra123

IS-IT--Management
Jun 17, 2001
54
CZ
Hi All,

I have a file with the following data in it

2004-01-01:01:00:00.00
339462,107461
2004-01-01:02:00:00.00
202765,72707

Is there any way of formatting the data so that I get out the put like this

2004-01-01:01:00:00.00 339462,107461
2004-01-01:02:00:00.00 202765,72707.

I do not want to use the cut paste technique as I am not sure about the integrity of the data, I tried a few things with awk and Sed but I did not get the desired output.

Any help is greatly appreciated.

prem.
 
You are in the right direction:

Code:
# n=0
# cat file.txt |awk '{ if(n==0) {n=1; printf "%s ",$1} else {n=0; printf "%s\n",$1}}'

"#" stand for command prompt.

Cheers.
 
Code:
# cat file.txt |awk '{ if(n==0) {n=1; printf "%s ",$1} else {n=0; printf "%s\n",$1}}' > new_file.txt
 
Try this...[tt]
paste -s -d' \n' file1 > file2
[/tt]
 
Hi Chacalinc,

It did work but what does the n option stand for ???

Hi Ygor,

Thanks once again it worked without awk. I am glad.

prem
 
Prem,

I believe Chanalinc is using the n variable to only set a newline at every other line.

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top