annotate tools/rdock/bin/to_unix @ 3:b02d74d22d05 draft default tip

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