Re: what's an equivalent for the following Perl one-liner?

2005-12-23 Thread Nikos Vassiliadis
On Thursday 22 December 2005 00:04, Mikhail Teterin wrote:
 I'd like a sed string, that will remove both the carriage returns and the
 blanks at eol in one go. Perl appears to recognize the \r character and
 DTRT:

   perl -p -e 's,[ \r]+$,,'  in  out

 What's the sed's equivalent? Thanks!

I thought only bash could do it, but I was wrong:

a=$'s/[ \r]\{1,\}$//'
sed $a

the shell will expand $'\r' to errr \r
and you can use as an one-liner
var=value sed $var

HTH, Nikos


   -mi
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Mikhail Teterin
I'd like a sed string, that will remove both the carriage returns and the 
blanks at eol in one go. Perl appears to recognize the \r character and DTRT:

perl -p -e 's,[ \r]+$,,'  in  out

What's the sed's equivalent? Thanks!

-mi
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Dan Nelson
In the last episode (Dec 21), Mikhail Teterin said:
 I'd like a sed string, that will remove both the carriage returns and
 the blanks at eol in one go. Perl appears to recognize the \r
 character and DTRT:
 
   perl -p -e 's,[ \r]+$,,'  in  out
 
 What's the sed's equivalent? Thanks!

sed -E 's,[ ^M]*$,,'  in  out

Note the ^M is a single control-character (entered via Ctrl-V Ctrl-M at
a shell prompt for example).  sed does not parse backslash-escapes
except for \n which represents a newline.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Mikhail Teterin
четвер 22 грудень 2005 13:32, Dan Nelson Ви написали:
 In the last episode (Dec 21), Mikhail Teterin said:
  I'd like a sed string, that will remove both the carriage returns and
  the blanks at eol in one go. Perl appears to recognize the \r
  character and DTRT:
 
  perl -p -e 's,[ \r]+$,,'  in  out
 
  What's the sed's equivalent? Thanks!

 sed -E 's,[ ^M]*$,,'  in  out

 Note the ^M is a single control-character (entered via Ctrl-V Ctrl-M at
 a shell prompt for example).

Yes, I used this in the past, but the ports' Makefiles are supposed to be 
ASCII-only :-(

 sed does not parse backslash-escapes except for \n which represents a
 newline.

Is not that a bug really? There may be some legacy reasons not to do it by 
default, but I'd expect the -E flag to turn on the recognition of such 
symbols...

Thanks!

-mi
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Tijl Coosemans
On Thursday 22 December 2005 20:14, Mikhail Teterin wrote:
 четвер 22 грудень 2005 13:32, Dan Nelson Ви написали:
  In the last episode (Dec 21), Mikhail Teterin said:
   I'd like a sed string, that will remove both the carriage returns
   and the blanks at eol in one go. Perl appears to recognize the \r
   character and DTRT:
  
 perl -p -e 's,[ \r]+$,,'  in  out
  
   What's the sed's equivalent? Thanks!
 
  sed -E 's,[ ^M]*$,,'  in  out
 
  Note the ^M is a single control-character (entered via Ctrl-V
  Ctrl-M at a shell prompt for example).

 Yes, I used this in the past, but the ports' Makefiles are supposed
 to be ASCII-only :-(

Try col(1) or tr(1) to remove the carriage return and then sed to remove 
the spaces.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Mikhail Teterin
 Try col(1) or tr(1) to remove the carriage return and then sed to remove
 the spaces.

Well, yes, but that's a two-stage process. A shame to go through the whole 
file twice just because our tools aren't good enough.

-mi
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: what's an equivalent for the following Perl one-liner?

2005-12-22 Thread Don Hinton
On Thursday 22 December 2005 13:52, Mikhail Teterin wrote:
  Try col(1) or tr(1) to remove the carriage return and then sed to remove
  the spaces.

 Well, yes, but that's a two-stage process. A shame to go through the whole
 file twice just because our tools aren't good enough.

How about this:

sed 's/ *[[:cntrl:]]$//' 

hth...
don

   -mi
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 [EMAIL PROTECTED]

-- 
Don Hinton don.hinton at vanderbilt.edu615.480.5667
ISIS, Vanderbilt University


pgpuOloR8y33y.pgp
Description: PGP signature