On removing ^M

Fafa Hafiz Krantz fteg at london.com
Mon May 9 12:13:23 PDT 2005


----- Original Message -----
From: "Giorgos Keramidas" <keramida at ceid.upatras.gr>
To: cpghost <cpghost at cordula.ws>
Subject: Re: On removing ^M
Date: Mon, 9 May 2005 13:29:46 +0300

> 
> 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 :-)


Very good! Thank you all!

So in conclusion, does this sh script look good?
I mean, can the first 3 commands be put like that?

$ chown -R fafa:wheel *

$ find . -type d -exec chmod 755 {} \;
$ find . -type f -exec chmod 644 {} \;

$ find . -type f | while read file ; do
   if grep '^M' "${file}" >/dev/null 2>&1 ; then
   sed -i '' -e 's/^M//g' "${file}"
   fi
done

Forever grateful! That's me.

--

Fafa Hafiz Krantz
  Research Designer @ http://www.home.no/barbershop
  Enlightened @ http://www.home.no/barbershop/smart/sharon.pdf



-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm



More information about the freebsd-questions mailing list