If you work on multiple platforms, occasionally you'll need to remove Windows line endings from files before working on them in Unix. I ran across a great tip on how to do this on Madross.com.

$ cd /director/with/your/file
$ find . -type f -exec perl -pi -e 's/\r\n?/\n/g' {} \;

The above recursively edits your directory. Or you can do this one file at a time:

$ perl -pi -e 's/\r\n?/\n/g' filename.txt

 

Add to My Yahoo!

Add to Google

Subscribe with Bloglines

Austin Gilbert/Male/26-30. Lives in United States/Oklahoma/Tulsa/Midtown, speaks English. Spends 40% of daytime online. Uses a Fast (128k-512k) connection. And likes computer science/photography.
This is my blogchalk: United States, Oklahoma, Tulsa, Midtown, English, Austin Gilbert, Male, 26-30, computer science, photography.

Unbake Windows Text Files on Unix
2008/06/28