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!

who to arrange dataset 2

Status
Not open for further replies.

valle70

IS-IT--Management
Jun 11, 2004
6
DK
Hi
"who -m" gives me following output
root
user1

"who -m|awk '{printf("%s",$1)}'" gives me following oupput
rootuser1

I would like make a awk script that orders the lines show below seperated by a _

root_user1

who do I do this ?

Regards
 
Try something like this:
who -m|awk '{printf "%s",(NR>1?"_":"")$1}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
there are sure better ways to do this,
but the answer to your question is:

who -m|awk '{printf("%s%s",(xx++) ? "_" : "",$1);}'

dont forget the closing ';' after ')' for syntax purists
be sure you are using the new-awk



:) guggach
 
bonjour PHV, en effet 'NR' est bien plus efficace que 'xx'
je corrige:

who -m|awk '{printf("%s%s",(NR >1) ? "_" : "",$1);}'



:) guggach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top