I use sed to create files from template files. I can’t figure out, using man sed, why it does not change all the matched strings.
If my file (template_file.txt) contains:
#!/bin/sh
#
# /etc/init.d/%SCRIPT_NAME% - Startup script for play %SCRIPT_NAME% engine
#
### BEGIN INIT INFO
[...]
EOF
Using :
sed -e "s;%SCRIPT_NAME%;script_test_name;" template_file.txt > script_test_name
Produces (script_test_name) :
#!/bin/sh
#
# /etc/init.d/script_test_name - Startup script for play %SCRIPT_NAME% engine
#
### BEGIN INIT INFO
[...]
EOF
I see that for lines which have 2 times the string to replace, only the first one is replaced.
Can you give me a hint how to fix it?
The
scommand changes only the first occurrence unless you add theg(global) modifier to it.