LJ Archive

Listing 1: DOS to Unix file conversion script


#!/bin/sh
# dos2unix <filename>
umask 600
[ -f "$1" ] || {
  echo "Please provide name of file to convert"
  exit 1
}
touch /tmp/d2u.$$.tmp || {
  echo "Couldn't create temporary file in /tmp"
  exit 2
}
tr --delete '\r\032' < $1 > /tmp/d2u.$$.tmp
cp /tmp/d2u.$$.tmp $1
rm /tmp/d2u.$$.tmp

LJ Archive