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

help on unix script

Status
Not open for further replies.

lamsf

Technical User
Jul 27, 2003
103
US
Hi,
I hv a file with the following contents (eg):

ABCDEF
1234567
GHIJ
23456

What command can I use to modify the file contents to become the following:

ABCDEF 1234567
GHIJ 23456

i.e. the 2nd line will join the 1st line, and so on.

Can someone pls help? Thanks a lot!
 
The paste man page says:

Example 3: Combine pairs of lines from a file into single lines.
paste -s -d"\t\n" file

Regards,
Dan
 
Thanks all for helping, really appreciate it.

I hv another question... Can I hv more than one delimiters? For eg. if I hv a file with contents:

12:34;56/78
ab:cd;ef/gh

For the above file, how can set the delimiter to be ":", ";" and "/"?

Thank you all in advance.
 
Would you want the output to be 12 ab; 34 cd... or 12 34 56 78 ab cd ... ? If you want the former, I'd suggest a perl script to take care of it.
 
nawk -v RS='[:;/\n]' '{printf $0 (++c%2?FS:ORS)}' file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top