I know, hating perl -- fish in a barrel. I've been doing a lot more
stuff in ruby lately, but I still like perl for a few things. In this
case, I had a file which had some spurious carriage returns, which I
needed to remove so postgres wouldn't complain about them. As it
happens, the carriage returns are also followed by a newline.
This should be a quick one liner:
perl -i.bak -ne 's/\r\n//;print' filename
So I run it, and now I have a file with no line endings, carriage
return or otherwise.
That's strange. So I look at it with good old 'od -c' -- sure enough,
no other carriage returns than the ones I'm trying to remove,
everything else is terminated only with newlines.
So:
perl -i.bak -ne 's/\r{1}\n{1}//;print' filename
And that works. I hate software that tries to be too clever,
especially in ways where the clever answer is only likely to be right
at best a plurality of the time.
ARRRGGGGGHHHH!!!!
d.