Search This Blog

Thursday, November 30, 2017

Sed replace a text with a variable of output of command

Sometimes we need to replace a string with a variable or output of a Linux command we can use Sed in following way to do that

sed -i "s/textTOreplace/${variablename}/g" /file_path

If you also want a backup of the original file to be created after replacement that you can use .bak after -i parameter as follows:

sed -i.bak "s/textTOreplace/${variablename}/g" /file_path





No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Ubuntu 27.04 "Tenacious T-Rex" – Everything We Know So Far!

  Ubuntu 27.04 "Tenacious T-Rex" – Everything We Know So Far! Ubuntu 27.04, nicknamed Tenacious T-Rex , is the upcoming Ubuntu Lin...