November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

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>