Friday, February 8, 2013

convert newline: dos to unix

#! /bin/bash

# converts dos/win line endings to unix

in=$1
out=$2

same=0

cmd=`basename $0`

if [ ! "$in" ]; then
echo "$cmd: convert dos/win line breaks to unix"
echo " Usage: $cmd INFILE [OUTFILE]"
exit 1
fi

if [ "$in" = "$out" ]; then
same=1
out=`tempfile`
fi

tr -d '\015' < "$in" > "$out"

if [ "$same" -eq 1 ]; then
fi

 

No comments:

Post a Comment