sed Question (FAQs answer doesn't work!)(Solved)

Booting, installing, newbie
Post Reply
Message
Author
User avatar
ozboomer
Posts: 135
Joined: Wed 04 May 2005, 21:22
Location: Melbourne, Australia

sed Question (FAQs answer doesn't work!)(Solved)

#1 Post by ozboomer »

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

Guest

#2 Post by Guest »

tmpdir=/tmp/root
echo /root/etc/hosts | sed "s%/root%$tmpdir%"

User avatar
ozboomer
Posts: 135
Joined: Wed 04 May 2005, 21:22
Location: Melbourne, Australia

#3 Post by ozboomer »

Anonymous wrote:tmpdir=/tmp/root
echo /root/etc/hosts | sed "s%/root%$tmpdir%"
Great. Many thanks. Forgot all about the other delimiters :)

Guest

#4 Post by Guest »

got beaten to the punch

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#5 Post by Flash »

Bladehunter: isn't it worth answering all those easy questions to find one like this one? :)

Post Reply