dos2unix / unix2dos
April 4th, 2006 by Jim
If you have ever found yourself on a Linux system that lacks the dos2unix or unix2dos commands, this reference may be helpful to you.
| dos2unix | |
| Single Command | Wrapper Script |
perl -pi -e 's/\\r//' [file] |
#!/bin/sh
# Copy to /usr/local/bin/dos2unix
if [ "$1" = "" ]; then
echo Usage: `basename $0` [filename]
exit
fi
# Convert to Unix format.
perl -pi -e 's/\\r//' $1
|
| unix2dos | |
| Single Command | Wrapper Script |
perl -pi -e 's/\\r//; s/\\n/\\r\\n/' [file] |
#!/bin/sh
# Copy to /usr/local/bin/unix2dos
if [ "$1" = "" ]; then
echo Usage: `basename $0` [filename]
exit
fi
# Force to Unix format first...
perl -pi -e 's/\\r//' $1
# ...and then convert to DOS.
perl -pi -e 's/\\n/\\r\\n/' $1
|
Revision History
| 2006.04.04 | Initial revision. |