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 with getline 1

Status
Not open for further replies.

sunixadm

Technical User
Sep 20, 2001
73
DE
Hello masters of awk,

I am a basic user of awk and need some help using getline and would appreciate any help you could offer.

I have a file name parts with this content:

ABS1234
ABS5678
ABS9101
ABS2175
ABS8234
ABS9876
ABS0765
ABS9937
ABS2254

I am trying to get the file to look like this:
ABS1234 ABS5678 ABS9101
ABS2175 ABS8234 ABS9876
ABS0765 ABS9937 ABS2254

This is what I have tried but need some help with please:
Code:
 awk '{ id1=$1;getline;id2=$1;getline;id3=$1;print $id1, $id2, $id3 }' parts
ABS9101 ABS9101 ABS9101
ABS9876 ABS9876 ABS9876
ABS2254 ABS2254 ABS2254
Thanks in advance for your help!
-Joe
 
Replace this:
print $id1, $id2, $id3

with this:
print id1, id2, id3

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV!

I guess I was trying to make it harder than it has to be!
Cheers,
-Joe
 
Another ways:
paste -s -d '\t\t\n' parts

pr -at -3 parts

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top