On Sat, 28 Apr 2001 at 10:14am (+0600), [EMAIL PROTECTED] wrote:

> Hi all
>
> I am trying to replace the letter "-r" with "-r new line"
>
> my command is like this
>
> # cat file |sed 's/-r/-r \n/g' > file2
>
> the result I get is "-r" is replace to be "-r n"
> what have I done wrong.
>

Sed wants you to use a literal newline char preceded by a \... So you could
do...

# cat file | sed 's/-r/-r\
> /g' > file2

... or

# cat file | sed 's/-r/-r\^J/g' > file2

where the ^J the is a literal ctrl-j which can be insterted by pressing
ctrl-v immediatly before hand to tell bash you want the next key press to be
inserted and not interpreted.

I guess which one you go with depends weither you want to do this on the
command line or in a script.

M.

-- 
WebCentral Pty Ltd           Australia's #1 Internet Web Hosting Company
Level 1, 96 Lytton Road.           Network Operations - Systems Engineer
PO Box 4169, East Brisbane.                       phone: +61 7 3249 2500
Queensland, Australia.                            pgp key id: 0x900E515F



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to