[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LF to CR Conversion



moxie@panix.com (Mark Mentovai) wrote:
>OK.....I think Nulib should be able to do this, but I can't figure out 
>how.  I want to know of a program for Unix that will change all Linefeeds 
>to Carriage Returns in a specified file, so I can compress it before 
>downloading it and having to worry about deleting pound-signs in 
>AppleWorks, which is a pain in the neck on large files, and the small 
>ones are starting to bug me now too.  <-- Long Sentence!

I just use the following script (which I call jtom):

#!/usr/bin/sh

pid=$$
trap "rm /tmp/jtom.$pid 2> /dev/null ; mv /tmp/jtom.$pid.2 $1 2> /dev/null; \
     exit" 15 2 1

while test $# -gt 0
do
/usr/bin/echo -n $1
/usr/bin/echo -n ' ... '
     cp $1 /tmp/jtom.$pid.2
     cat $1 | tr \\012 \\015 > /tmp/jtom.$pid
     mv /tmp/jtom.$pid $1
     rm /tmp/jtom.$pid.2
     shift
/usr/bin/echo 'done'
done


To convert ^M's to ^J's, just switch the \\012 and \\015.