On removing ^M

Giorgos Keramidas keramida at ceid.upatras.gr
Mon May 9 03:30:13 PDT 2005


On 2005-05-09 12:21, cpghost <cpghost at cordula.ws> wrote:
>On Mon, May 09, 2005 at 12:34:08AM +0300, Giorgos Keramidas wrote:
>> No "tool" is needed, as long as you have FreebSD's shell, sed & grep:
>>
>> 	$ find . | while read fname ;do
>> 	    if grep '^M' "${fname}" >/dev/null 2>&1 ;then
>> 		sed -i '' -e 's/^M//g' "${fname}"
>> 	    fi
>> 	  done
>
> Wouldn't this also catch directories or special files with ^M in them?
> I'd add a "-type f" to find to avoid errors while trying to write to
> a directory:
>
> $ find . -type f | while read fname ;do
>     if grep '^M' "${fname}" >/dev/null 2>&1 ;then
>         sed -i '' -e 's/^M//g' "${fname}"
>     fi
>   done

Yes.  You're right, of course :-)



More information about the freebsd-questions mailing list