CyberKeeda In Social Media

Sed to add string before or after your word.


So i was googling the same and found the exact thing i was looking for, and you too are at the right place.

Let us consider, i got a word as  "host" within a file as myfile.txt

#cat myfile.txt

host

Now my requirement is to add

  • "secure" at the beginning of host to make it as "securehost"




Command for it -:  #sed -e 's/^/secure/' myfile.txt

  • add "linuxbot" at the end to make it as "hostlinuxbot"

Command for it -:  #sed -e 's/$/linuxbot/' -i myfile.txt

No comments:

Post a Comment

Designed By Jackuna