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

Hostname next to node name in file

Status
Not open for further replies.

maxcrook

Programmer
Joined
Jan 25, 2001
Messages
210
Location
GB
I have a file that contains date like so

server1
server2
server3
server4

What i need to do is to output the hostname to the file placing it on each line next to the server ie

server1 tsm1
server2 tsm1
server3 tsm1

Hope that makes sense!
 
A couple of ways.

nawk -v host=`hostname` '{print $0 " " host}' datafile

or

awk '{print $0 " " host}' host=`hostname` datafile

Greg.
 
Hi greg thanks very much for these - spot on exactly what i wanted.
Brilliant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top