File: to_unix

package info (click to toggle)
blender 2.46%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 68,208 kB
  • ctags: 77,061
  • sloc: ansic: 518,049; cpp: 199,438; python: 67,585; sh: 7,097; makefile: 3,572; perl: 2,082; java: 8
file content (30 lines) | stat: -rwxr-xr-x 486 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /bin/sh -e
#Tag 1538
#
# convert a DOS ASCII file to a UNIX ASCII file by removing trailing ^M at the
# end of each line and ^Z at the end of the file

TMPFILE=/tmp/to_unix$$

if [ $# -gt 2 ]
then
	echo "usage: to_unix [<dos_file> [<unix_file>]]"
	exit 1
fi

# First strip out all carriage-return and ctrl-Z's
if [ $# -gt 0 ]
then
	tr -d '\015\032' < "$1" > $TMPFILE
else
	tr -d '\015\032' > $TMPFILE
fi


if [ $# -eq 2 ]
then
	mv -f $TMPFILE "$2"
else
	cat $TMPFILE
	rm $TMPFILE
fi