snovotill@yahoo.com [sed-users]
2018-04-04 04:07:06 UTC
I was reading the excellent SED FAQ bud could not find an alternate solution to the following:
The script below replaces the literal string $path with the contents of variable $usb
The only way I could get this to work under busybox ash is with completely bare \\$
to escape the literal $path in two separate chunks as \\$'path' which is REALLY weird.
***@zero:~# usb='/mnt/stick'; echo 'Path $path is it!' | sed -r 's|'\\$'path'"|$usb|g"
Path /mnt/stick is it!
It's great that it works because it allows me to pre-process my here-block before I
write it out to a file, but jeepers it would be nice to understand what's happening
and whether there are any other ways to do this under busybox with ash.
Here is the slightly simplified here-doc version which I actually use:
usb='/mnt/stick'
cat <<-'EOF' | sed -r 's|'\\$"path|$usb|g"
echo and here it is:
ftpdir=$path
echo more stuff
EOF
Best regards
Stepan Novotny
[Non-text portions of this message have been removed]
The script below replaces the literal string $path with the contents of variable $usb
The only way I could get this to work under busybox ash is with completely bare \\$
to escape the literal $path in two separate chunks as \\$'path' which is REALLY weird.
***@zero:~# usb='/mnt/stick'; echo 'Path $path is it!' | sed -r 's|'\\$'path'"|$usb|g"
Path /mnt/stick is it!
It's great that it works because it allows me to pre-process my here-block before I
write it out to a file, but jeepers it would be nice to understand what's happening
and whether there are any other ways to do this under busybox with ash.
Here is the slightly simplified here-doc version which I actually use:
usb='/mnt/stick'
cat <<-'EOF' | sed -r 's|'\\$"path|$usb|g"
echo and here it is:
ftpdir=$path
echo more stuff
EOF
Best regards
Stepan Novotny
[Non-text portions of this message have been removed]