problem with sed substitution
Frank Shute
frank at esperance-linux.co.uk
Wed Jun 20 01:35:40 UTC 2007
On Tue, Jun 19, 2007 at 06:58:17PM +0200, Olivier Regnier wrote:
>
> Hi everyone,
>
> I try to use sed with /etc/gettytab file. I would like to replace this
> text :
> \r\n%s\%m ($h) (%t)\r\n\r by Hello world.
> I tested with this command :
> % sed -i.old -e 's/\r\n%s\%m ($h) (%t)\r\n\r/Hello world/'
> but that doesn't work at all.
> Can you help me please ?
>
> Thank you :)
>
You have to backslash escape the characters "\()% "
So eg:
cat /etc/gettytab | \
sed -E 's/\\r\\n\%s\/\%m\ \(\%h\)\ \(\%t\)\\r\\n\\r/Hello world/' > ~/new_getty
PS: I checked it on my gettytab which looks like it's a bit different
to yours.
BTW, re_format(7) is worth a look.
--
Frank
echo "f r a n k @ e s p e r a n c e - l i n u x . c o . u k" | sed 's/ //g'
--->PGP keyID: 0x10BD6F4B<---
More information about the freebsd-questions
mailing list