Friday, April 4, 2014

appending string after end of each line

I have a File that contains list of servers and I just want to append a domain-name (say .xyz.com ) at the end of line.

# head -5 serverlist.txt
server1
server2
server3
server4
server5
# sed  -ie 's/$/.xyz.com/' serverlist.txt
# head -5 serverlist.txt
server1.xyz.com
server2.xyz.com
server3.xyz.com
server4.xyz.com
server5.xyz.com
#

Another method using Awk:
awk '{ print $0 ".xyz.com" }' < serverlist.txt > resultfile.txt

No comments:

Post a Comment

Popular Posts

About Me

My photo
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).