April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

dos2unix / unix2dos

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

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>