USAGE="##################################################################### # atou / utoa / mtou (AppleToUnix or UnixToApple MsdosToUnix) # December 15, 1990 - Evan Ron Aussenberg # erast1@unix.cis.pitt.edu # IN%\"erast1@pittunix\" # # Discription: # An Apple-to-Unix, Unix-to-Apple, MSDOS-to-Unix text file # converter. This is a Unix shell script. If you don't use Unix # then you don't need this (Well... maybe you do, but you can't use it). # # Disclaimer: # You're mileage may differ. Also, this is just a little # nicer than making a t/csh alias... and it'll run from any shell # as long as you leave the ':' in the 1st line. Okay? Okay. # # To run this shell script you need : # 1: The unix command \#basename\# | Just make sure these programs can # 2: The unix command \#tr\# | be found in your $PATH environ. # 3: Save this program as \#utoa\# # 4: Type \#chmod a+x utoa\# # 5: Type \#ln utoa atou\# | If you don't have the command # | \#ln\# or \#link\# then use \#cp\# # # Syntax: # atou [-v | V] file1 files2... # utoa [-v | V] file1 files2... # mtou [-v | V] file1 files2... # utom [-v | V] file1 files2... # mtoa [-v | V] file1 files2... # # Use atou folllowed my utom to get atom # # Options (specifiy only one): # -v Give terse output. Normally no output is given. # -V Give verbose output # ######################################################################## " command=`basename $0` # What command has called us here? verb='0' case $command in utoa) oct1="\012" # This is control-j octal oct2="\015";; # This is control-m octal atou) oct1="\015" # This is control-m octal oct2="\012";; # This is control-j octal mtou) oct1="\015" # This is control-m octal oct2="" ;; # Translate it to null mtoa) oct1="\012" # This is control-j octal oct2="";; # Translate it to null utom) oct1="\012" oct2='utom' ;; *) echo "Hey, please name this program utoa, atou, mtou or utom" oct1="" oct2="";; esac # Check any options. If you're file is actually named "-v or -V" # and you're a unix neophyte... hee hee. case $1 in -v ) verb=1 ; shift ;; -V ) verb=2 ; shift ;; * ) ;; esac # Check to make sure some files were specified if [ $# = 0 ] then echo "$USAGE" exit 2 fi for file in $* do if [ -f $file ] then [ $verb = 1 ] && echo -n $command': '$file'... ' [ $verb = 2 ] && echo -n $command': Saving '$file' to '$command.$$'... ' if [ "$oct2" = "" ] then cat $file | tr -d "$oct1" > $command.$$ [ $verb -gt 0 ] && echo "done $command." [ $verb = 2 ] && echo $command': Moving '$command.$$' to '$file mv $command.$$ $file [ $verb = 2 ] && echo continue fi if [ "$oct2" = "utom" ] then awk ' BEGIN { outfile = ARGV[1] ARGV[1] = "" } { x = $0 "\r" print x >> outfile }' $command.$$ $file [ $verb -gt 0 ] && echo "done $command." [ $verb = 2 ] && echo $command': Moving '$command.$$' to '$file mv $command.$$ $file [ $verb = 2 ] && echo "mv command in awk just finished" continue fi # fi cat $file | tr $oct1 $oct2 > $command.$$ [ $verb -gt 0 ] && echo "done vanilla $command." [ $verb = 2 ] && echo $command': Moving '$command.$$' to '$file mv $command.$$ $file [ $verb = 2 ] && echo else if [ -d $file ] then echo "${command}: $file is a directory - skipping" else echo "${command}: Can't find $file... Skipping" fi fi done