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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split one column into two 4

Status
Not open for further replies.

rks11

Technical User
Oct 16, 2006
2
DE
I would like to be able to modify the following output in filename.txt from this:

alpha
56%
beta
72%
charlie
88%
...

to this:

alpha 56%
beta 72%
charlie 88%
...

Hope you can help me. Thanks.
 
Code:
nawk '{ORS=(i=!i)?FS:RS}1' a.txt
OR
nawk 'ORS=(FNR%2)?FS:RS' a.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I have to agree, I was staring at it for quite some time before I understood it. [3eyes]

Annihilannic.
 
Another simple way:
paste -s -d " \n" /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you for your assistance Gurus.

[thumbsup2]

The following worked perfectly:

Code:
 /usr/xpg4/bin/awk '{printf $0" ";getline}1' filename.txt 

nawk 'ORS=(FNR%2)?FS:RS' filename.txt

paste -s -d " \n" filename.txt




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top