To convert a file from unix format to DOS, you can use the following script. Note that on recent unix systems this script comes built-in....
#! /bin/sh
if [ ! "$1" ] ; then
echo `basename $0` file ...
echo ' convert' filenames from unix to dos file format
exit 1
fi
while [ "$1" ] ; do
TMP=$1.$$
awk 'sub("$", "\r")' $1 > $TMP
cp -f "$TMP" "$1"
rm -f "$TMP"
shift
done
Thursday, March 27, 2008
Thursday, March 6, 2008
dos2unix shell script
To convert a file from DOS format to unix format, you can use the following script. Note that on recent unix systems this script comes built-in....
#! /bin/sh
if [ ! "$1" ] ; then
echo `basename $0` file ...
echo ' convert' filenames from dos to unix
exit 1
fi
while [ "$1" ] ; do
TMP=$1.$$
if tr -d '\r' <"$1" >"$TMP" ; then
cp -f "$TMP" "$1"
fi
rm -f "$TMP"
shift
done
#! /bin/sh
if [ ! "$1" ] ; then
echo `basename $0` file ...
echo ' convert' filenames from dos to unix
exit 1
fi
while [ "$1" ] ; do
TMP=$1.$$
if tr -d '\r' <"$1" >"$TMP" ; then
cp -f "$TMP" "$1"
fi
rm -f "$TMP"
shift
done
Subscribe to:
Posts (Atom)