sed Question (FAQs answer doesn't work!)(Solved)
Posted: Sun 14 Aug 2005, 12:21
This is sending me silly...
Using puppy v1.0.1 or v1.0.4...
# tmpdir=/tmp/root
# echo /root/etc/hosts | sed 's/root/abc/'
...gives /abc/etc/hosts
# echo /root/etc/hosts | sed 's/root/$tmpdir/'
...gives /$tmpdir/etc/hosts
# echo /root/etc/hosts | sed "s/root/$tmpdir/"
...gives "sed: -e expression #1, char 9: Unknown option to 's'"
The sed FAQs suggest the variable substitution happens when the double-quotes are used... but all I get is the syntax error.
Gnu sed v4.0.7 is included in both Puppy v1.0.1 and v1.0.4.
What do I have to do to get the variable substitution to work!?
John
Using puppy v1.0.1 or v1.0.4...
# tmpdir=/tmp/root
# echo /root/etc/hosts | sed 's/root/abc/'
...gives /abc/etc/hosts
# echo /root/etc/hosts | sed 's/root/$tmpdir/'
...gives /$tmpdir/etc/hosts
# echo /root/etc/hosts | sed "s/root/$tmpdir/"
...gives "sed: -e expression #1, char 9: Unknown option to 's'"
The sed FAQs suggest the variable substitution happens when the double-quotes are used... but all I get is the syntax error.
Gnu sed v4.0.7 is included in both Puppy v1.0.1 and v1.0.4.
What do I have to do to get the variable substitution to work!?
John