RE: Re: getting rid of ^M
tony@servacorp.com
tony at servacorp.com
Fri Sep 1 01:58:26 PDT 2006
florin.i at tiscali.it wrote:
>
>--0OAP2g/MAC+5xKAE
>Content-Type: text/plain; charset=us-ascii
>Content-Disposition: inline
>
>Craig Hammond dixit (2006-09-01, 10:20:04):
>
>> After FTPing a heap of files from Windows to
>OBSD, I have found that a
>> lot of the text them have a ^M at the end of each
>line. Is there any
>> easy way to recursively strip out the ^M of all
>affected files in a
>> number of directories.
>
>Use something like this, where ^M is obtained by
>pressing CTRL-V
>followed by CTRL-M:
>
>for i in `ls`; do sed 's/^M//g' $i > $i.new;done
>
This may be an OUCH
DOS text lines end with <Carriage-Return><Line-Feed>
UNIX text lines end with <Line-Feed>
Apple text lines end with <Carriage-Return> (or some such)
FTP transfers from one kind of system to another will take care of the different line-endings on an ASCII transfer.
An ASCII transfer of a binary file tends to wreck the file. Getting rid of all the Carriage-Returns (anywhere in the file) would do even more damage.
Unixy systems may have a pair of dos2unix and unix2dos programs designed to convert text files from one kind to the other.
More information about the Openbsd-newbies
mailing list