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!

Awk Script or Recommendations.. 1

Status
Not open for further replies.

driddickemc

IS-IT--Management
May 3, 2004
42
US
Have a text file..e.g.

Host1 wwna
Host1 wwnb
Host2 wwna
Host2 wwnb

Want to parse the file to look like..

Host1 wwna wwnb
Host2 wwna wwnb

about 30 lines.. New to scripting..please help..
 
nawk -f drid.awk myFile

drid.awk:
Code:
{ arr[$1] = ($1 in arr) ? arr[$1] OFS $2 : $2 }
END {
  for (i in arr)
    print i, arr[i]
}

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
A starting point:
awk '{h[$1]=h[$1]" "$2}END{for(i in h)print i h}' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top