I have a skeleton text file with placeholder strings:
blah blah blah
blah $PLACEHOLDER_1$
blah
$PLACEHOLDER_2$
and so on. Specific \"form\" of
Building on the previous answer, perhaps use an array and compute the sed string?
#!/bin/sh
PLACEHOLDER[0]='string 1'
PLACEHOLDER[1]='multiline
string
2'
s="sed -i "
for(( i=0 ; i<${#PLACEHOLDER[*]} ; i++ )) ; do
echo ${PLACEHOLDER[$i]}
s=$s"s/PLACEHOLDER_$i/${PLACEHOLDER[$i]}/g;"
done
echo $s
Seems to fail on the multi-line strings, though.
I don't know how portable Bash arrays might be. Above snippet tested with "GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)"