Newsgroups: comp.sys.apple2 Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!pacbell.com!att-out!cbnewsd!bird From: bird@cbnewsd.cb.att.com (j.l.walters) Subject: LF -> CR, etc. Organization: AT&T Date: Sun, 14 Mar 1993 03:13:27 GMT Message-ID: <1993Mar14.031327.6455@cbnewsd.cb.att.com> Lines: 121 The following was posted some time ago. It allowed converting from Unix(R) to Apple and Apple to Unix. I added MSDOS to Unix. In order to go from MSDOS to Apple you would use: mtou filename followed by utoa filename. Note that normal Unix wildcards work. The "secret" to using this command is to store it with a name of: 1. utoa 2. ln utoa atou 3. ln utoa mtou The link command (ln) "fools" Unix into believing there is a separate command with the given name. When you invoke the tool with one of the given names the $0 allows it to decide just what to do. Hope this helps, ================================= cut here ================================= : ##################################################################### # atou / utoa / mtou (AppleToUnix or UnixToApple or 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... # # 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? verbose='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 *) echo "Hey, please name this program utoa, atou or mtou" exit 1; 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 ) verbose=1 ; shift ;; -V ) verbose=2 ; shift ;; * ) ;; esac # Check to make sure some files were specified if [ $# -gt 0 ] then for file in $* ; do if [ -f $file ] ; then [ $verbose = 1 ] && echo -n $command': '$file'... ' [ $verbose = 2 ] && echo -n $command': Saving '$file' to '$command.$$'... ' cat $file | tr $oct1 $oct2 > $command.$$ [ $verbose -gt 0 ] && echo 'done.' [ $verbose = 2 ] && echo $command': Moving '$command.$$' to '$file mv $command.$$ $file [ $verbose = 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 else echo -n ' '$command': No file names specified! Syntax: atou [-v | V] file1 files2... utoa [-v | V] file1 files2... ' exit 1 fi echo exit 0 -- Joe Walters att!ihlpm!bird, IH 2A-227 (708) 224-7189 To know, and not to do, is not yet to know