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

Nikos Vassiliadis nvass at teledome.gr
Fri Dec 23 06:57:22 PST 2005


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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list