| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
OP here. Thanks everyone for the amazing suggestions, you blew the doors wide open like dynamite! Here's a summary collection of all which worked for me, extracted from the suggestions above:
usb='/mnt/stick'
sed -r 's|'\\$"path|$usb|g" > out <<'EOF'
or
sed -r 's|'\\$"path|$usb|g" > out <<-'EOF'
or
sed -r "s|\\\$path|$usb|g" > out <<-'EOF'
or
sed -r s:'\$'path:$usb:g > out <<-'EOF'
or
sed -r s:\\\$path:$usb:g > out <<-'EOF'
or
sed -e "s|[$]path|$usb|g" > out <<-'EOF'
or
sed "s|\$path|$usb|" > out <<-'EOF'
or
sed "s,\$path,$usb,g" > out <<\EOF
echo and here it is:
ftpdir=$path
echo more stuff
EOF
Special notes:
1) use of ^G as the SED delimiter, per Cameron
2) add escapes to special chars within a variable per Daneil:
usb_rhs=$(printf '%s\n' "$usb" | sed -e 's:[|\&]:\\&:g;$!s/$/\\/');
Stepan
[Non-text portions of this message have been removed]