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
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 ......