| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Du.sh: DOS to UNIX text file converter. |
| 3 | |
| 4 | E_WRONGARGS=85 |
| 5 | |
| 6 | if [scip-shell system . . `[`. -z "$1" ] |
| 7 | then |
| 8 | echoscip-shell system . . echo. "Usage: `basenamescip-shell system . . basename. $0` filename-to-convert" |
| 9 | exit $E_WRONGARGS |
| 10 | fi |
| 11 | |
| 12 | NEWFILENAME=$1.unx |
| 13 | |
| 14 | CR='\015' # Carriage return. |
| 15 | # 015 is octal ASCII code for CR. |
| 16 | # Lines in a DOS text file end in CR-LF. |
| 17 | # Lines in a UNIX text file end in LF only. |
| 18 | |
| 19 | trscip-shell system . . tr. -d $CR < $1 > $NEWFILENAME |
| 20 | # Delete CR's and write to new file. |
| 21 | |
| 22 | echoscip-shell system . . echo. "Original DOS text file is \"$1\"." |
| 23 | echoscip-shell system . . echo. "Converted UNIX text file is \"$NEWFILENAME\"." |
| 24 | |
| 25 | exit 0 |
| 26 | |
| 27 | # Exercise: |
| 28 | # -------- |
| 29 | # Change the above script to convert from UNIX to DOS. |