Date: Mon, 09 May 2005 14:13:21 -0500 From: "Fafa Hafiz Krantz" <fteg@london.com> To: "Giorgos Keramidas" <keramida@ceid.upatras.gr>, cpghost <cpghost@cordula.ws> Cc: freebsd-questions@freebsd.org Subject: Re: On removing ^M Message-ID: <20050509191321.924034BEAE@ws1-1.us4.outblaze.com>
next in thread | raw e-mail | index | archive | help
----- Original Message ----- From: "Giorgos Keramidas" <keramida@ceid.upatras.gr> To: cpghost <cpghost@cordula.ws> Subject: Re: On removing ^M Date: Mon, 9 May 2005 13:29:46 +0300 >=20 > On 2005-05-09 12:21, cpghost <cpghost@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 >=20 > 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 --=20 ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050509191321.924034BEAE>