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

awk

Status
Not open for further replies.

hammam02

IS-IT--Management
Mar 23, 2009
27
0
0
EG
awk '{print $1}'

my output is

swiss
admin

i need swiss admin in the one line
 
There is a special variable within awk called RS stands for Record Separator. It defaults into a newline. You need to change it to a space.

Code:
RS     input record separator (default newline)

Code:
awk 'BEGIN { RS = " " }
          { print $1 }' Input_File

All you need about awk can be found here:


Regards,
Khalid
 
awk '{print $1}'|paste --

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
If datafile contains:

swiss
admin

then this places everything on one line:

Code:
xargs < datafile

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top