Re: [SLUG] Sed and ^M

2003-02-18 Thread Jamie Wilkinson
This one time, at band camp, Daniel Harper wrote:

Anyone know how to rip ^M (dos line return) using sed?

tr -d '\r' will remove ^Ms from a stream.

-- 
[EMAIL PROTECTED]   http://spacepants.org/jaq.gpg
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-17 Thread mlh
On 17 Feb 2003 15:05:08 +1100
Ken Foskey [EMAIL PROTECTED] wrote:

 On Mon, 2003-02-17 at 13:23, Daniel Harper wrote:
  Anyone know how to rip ^M (dos line return) using sed?
 
 without reading the manual you might try 's/\r//g' this is definitely
 not portable, if not use hex characters \015 from memory again...

I've never been able to figure out a portable way
to mangle control chars with sed.

Use tr is the standard advice, I think:

echo '^M' | tr -d '\012' 



Matt
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-17 Thread David Fitch
On Mon, 2003-02-17 at 20:44, [EMAIL PROTECTED] wrote:
 I've never been able to figure out a portable way
 to mangle control chars with sed.

if it's cos you're trying to use a dos file then just
run 'dos2unix' over the file (and vice versa use 'unix2dos').

Dave.

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-17 Thread mlh
On 17 Feb 2003 21:07:20 +1030
David Fitch [EMAIL PROTECTED] wrote:

 On Mon, 2003-02-17 at 20:44, [EMAIL PROTECTED] wrote:
  I've never been able to figure out a portable way
  to mangle control chars with sed.
 
 if it's cos you're trying to use a dos file then just
 run 'dos2unix' over the file (and vice versa use 'unix2dos').

Yeah, but I never really trusted those programs, since
(on Solaris at least) they always whinge about character
sets or locales or something.

And it seems my suspicion is not unwarranted:

[mlh@localhost mlh]$ od -xc stuff
000 0a0d
 \r  \n
002
[mlh@localhost mlh]$ cat stuff|dos2unix|od -xc
000 000a
 \n  \0
001


What the hell is that null doing there?


--
Matt

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-17 Thread David Fitch
On Mon, 2003-02-17 at 23:12, [EMAIL PROTECTED] wrote:
 Yeah, but I never really trusted those programs, since
 (on Solaris at least) they always whinge about character
 sets or locales or something.

never had any such problems (linux and solaris)

 And it seems my suspicion is not unwarranted:
 
 [mlh@localhost mlh]$ od -xc stuff
 000 0a0d
  \r  \n
 002
 [mlh@localhost mlh]$ cat stuff|dos2unix|od -xc
 000 000a
  \n  \0
 001
 
 
 What the hell is that null doing there?

what's wrong with it?

Dave.

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-17 Thread mlh
On 17 Feb 2003 23:09:20 +1030
David Fitch [EMAIL PROTECTED] wrote:


  What the hell is that null doing there?
 
 what's wrong with it?

I expected dos2unix to just convert \r\n to a single \n.

I don't expect to get a null in a text file.

Matt
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



[SLUG] Sed and ^M

2003-02-16 Thread Daniel Harper

Anyone know how to rip ^M (dos line return) using sed?
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug



Re: [SLUG] Sed and ^M

2003-02-16 Thread Ken Foskey
On Mon, 2003-02-17 at 13:23, Daniel Harper wrote:
 Anyone know how to rip ^M (dos line return) using sed?

without reading the manual you might try 's/\r//g' this is definitely
not portable, if not use hex characters \015 from memory again...
-- 
Thanks
KenF
OpenOffice.org developer

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug