On Fri, Sep 16, 2011 at 12:58:08PM -0600, Bob Proulx wrote: > Using sed is a good tool for this but if you want to append then you > should use the 'a' command. > > $ printf "one\ntwo\nthree\nfour\n" | sed '/two/a\ > -> foo' > one > two > -> foo > three > four
This doesn't quite work for me in this scenario either:
printf "<pre>\nSome text\n</pre>" | sed '/<pre>/a\n'
gives me
<pre>
n
Some text
</pre>
while: print "<pre>\nSome text\n</pre>" | sed '/<pre>/a\\n'
gives:
<pre>
Some text
</pre>
note there's two blank lines inserted above. How would I append a single
newline here? From the results above passing no argument to the append
command would suffice, but that isn't allowed.
I'm either overlooking something obvious, there's a problem with my
locale (en_GB.UTF-8), or there's a bug in sed. Any ideas anyone? I know
I'm more inclined to go with the first option :)
Cheers,
Tom
P.S. Hmm, while testing before sending this I discovered that
sed '/<pre>/a\\' works. Not what I would have expected.
--
<joost> Do you mean to say that I can read mail with vi too? ;-)
<Joey> Didn't you know that?
<Joey> :r /var/spool/mail/jk
-- Seen on #debian-mentors
signature.asc
Description: Digital signature

