Solved Help with sed insert from file
-
I am trying to insert the contents of a text file into a configuration file using
sed
sed -i 's/string_in_file/r /home/user/textfile' -r /dir/conf.file
So I want to replace
string_in_file
with the contents of/home/user/textfile
Help
-
Found the answer here:
https://unix.stackexchange.com/questions/32908/how-to-insert-the-content-of-a-file-into-another-file-before-a-pattern-markersed 's/CHANGEME/$x/g' origfile | x="$(<file2insert)" envsubst '$x' > newfile
This will replace every CHANGEME occurence in origfile with the content of file2insert. Remove last g from sed to replace only the first occurrence of CHANGEME.