10/29/11

DOS to UNIX text file conversion script


1 #!/bin/bash
2 # du.sh: DOS to UNIX text file converter.
3
4 E_WRONGARGS=65
5
6 if [ -z "$1" ]
7 then
8 echo "Usage: `basename $0` filename-to-convert"
9 exit $E_WRONGARGS
10 fi
11
12 NEWFILENAME=$1.unx
13
14 CR='\015' # Carriage return.
15 # Lines in a DOS text file end in a CR-LF.
16
17 tr -d $CR < $1 > $NEWFILENAME
18 # Delete CR and write to new file.
19
20 echo "Original DOS text file is \"$1\"."
21 echo "Converted UNIX text file is \"$NEWFILENAME\"."
22
23 exit 0

No comments:

Quick HTTP to HTTPS - Apache2

There are several methods for redirecting your Apache-based website visitors who might type your servers URL using the plain (non-secure) HT...