comparison tools/rdock/bin/to_unix @ 2:0faa03a92843 draft default tip

Uploaded
author dzesikah
date Fri, 26 Aug 2016 10:19:49 -0400
parents
children
comparison
equal deleted inserted replaced
1:ad4bc82457e5 2:0faa03a92843
1 #! /bin/sh -e
2 #Tag 1538
3 #
4 # convert a DOS ASCII file to a UNIX ASCII file by removing trailing ^M at the
5 # end of each line and ^Z at the end of the file
6
7 #DM 23 Oct 2000 - tmp file in current directory, not /tmp
8 #TMPFILE=/tmp/to_unix$$
9 TMPFILE=to_unix$$
10
11 if [ $# -gt 2 ]
12 then
13 echo "usage: to_unix [<dos_file> [<unix_file>]]"
14 exit 1
15 fi
16
17 # First strip out all carriage-return and ctrl-Z's
18 if [ $# -gt 0 ]
19 then
20 tr -d '\015\032' < "$1" > $TMPFILE
21 else
22 tr -d '\015\032' > $TMPFILE
23 fi
24
25
26 if [ $# -eq 2 ]
27 then
28 mv -f $TMPFILE "$2"
29 else
30 cat $TMPFILE
31 rm $TMPFILE
32 fi