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

Installing And Exploring Auto Dark Mode Software

Windows Auto--Night--Mode: Simplify Your Theme Switching   Windows Auto--Night--Mode is a free and lightweight tool that makes switching bet...