So we have all come across the situation: you copy a bunch of files from DOS/Windows to Unix and the newline characters are all messed up (in other words, you see a "^M" at the end of each line). So the scripts you wrote lovingly, are all messed up now.
There are two choices:
Use dos2unix - this will change the newline characters one file at a time. Trouble is, that dos2unix writes to stdout, so you'd have to pipe the output to a temporary file and move it back to your script...
Use the following perl one-liner:
perl -pi -e 's/\r\n/\n/g' *
You guessed it - Windows/DOS uses "\r\n" for newline, while Unix uses only "\n"
2009-04-16
Back again
Wow, it's been a while that I've been here... there's just been way too much travel..
I'm currently in Romania, after surviving a near death experience in a local taxi (which of all things, was about to hit a Police car, or maybe it was the other way around)... no one was hurt, though I was shaken... a lot!
I'm going to try to be more regular here now.
I'm currently in Romania, after surviving a near death experience in a local taxi (which of all things, was about to hit a Police car, or maybe it was the other way around)... no one was hurt, though I was shaken... a lot!
I'm going to try to be more regular here now.
Subscribe to:
Posts (Atom)