swapping ip and hostname in /etc/hostfile

T

torajeshkg

Guru's of Perl,

i have host file and i want to swap hostname and ip address fields ?

thx in advance
grk
 
J

John W. Krahn

Jim said:
Guru's of Perl,

i have host file and i want to swap hostname and ip address fields ?

perl -lane 'if(/^\s*#/){print;}else{print"$F[1]\t$F[0]";}' /etc/hosts

perl -i~ -lape'/^\s*#/||($_="$F[1]\t$F[0]")' /etc/hosts


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top