How to replace a text in file using linux

in linux •  7 years ago  (edited)

If you want to replace a text in file you have to use sed:

sed -i.bak s/STRING_TO_BE_REPLACED/NEW_STRING/g ./file.txt

If you want to add a text in specific line:

sed -e '2439iLINE_TO_ADD' -i ./file.txt

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @dviejo! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Do not miss the last announcement from @steemitboard!