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

arrange row to column

Status
Not open for further replies.

RC13

Technical User
Mar 27, 2003
1
SG
Assume the below text file;
*****************
freq S11
1 11
2 22
3 33

freq S21
1 111
2 222
3 333
*****************
I need to make it to;
*****************
freq S11 S22
1 11 111
2 22 222
3 33 333
*****************

I have more than 100 of this files to process.
I wonder awk can do this?
Thanks.

 
Indeed...
[tt]awk '/./ {a[$1]=a[$1] $2 &quot; &quot;} END {for(n in a) print n, a[n]}' <file |sort -n[/tt]
Gives...
[tt]freq S11 S21
1 11 111
2 22 222
3 33 333[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top