DOS-to-UNIX file conversion
How to replace CR LF with LF
The following one-liners removes the annoying ^M at the end of each line from files created in DOS:
# WARNING! For UNIX only! Do not use with ActivePerl in MSYS shell on Windows!# (Returns error message and file is deleted.)
perl -pi -e 's/\r\n/\n/g' filename
Using sh or bash:
# Works fine even in MSYS shell on Windows.
tr -d '\r' < original_filename > new_filename
(Note that the "<" and ">" must be typed for this command to work).
The same replacing technique can of course be applied to any string.
The following one-liner changes the 'cellpadding' value from 4 to 2 in all files in the current directory where the 'cellpadding' value is 4, and the 'cellspacing' value is 1:
# WARNING! For UNIX only! Do not use with ActivePerl in MSYS shell on Windows!# (Returns error message and deletes ALL files in directory!)
perl -pi -e 's/cellpadding=\"4\" cellspacing=\"1\"/cellpadding=\"2\" cellspacing=\"1\"/g' *
Last modified: Wed Oct 03 09:07:16 Romance Daylight Time 2007