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

Mikhail Teterin mi+mx at aldan.algebra.com
Thu Dec 22 11:14:24 PST 2005


четвер 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


More information about the freebsd-questions mailing list