From owner-freebsd-questions@FreeBSD.ORG Mon May 9 10:30:12 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D5E2E16A55E for ; Mon, 9 May 2005 10:30:12 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA7B943D39 for ; Mon, 9 May 2005 10:30:04 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])j49ASJYh021658; Mon, 9 May 2005 13:28:20 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) j49ATl3G005116; Mon, 9 May 2005 13:29:47 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)j49ATkdk005076; Mon, 9 May 2005 13:29:46 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 9 May 2005 13:29:46 +0300 From: Giorgos Keramidas To: cpghost Message-ID: <20050509102946.GA2740@orion.daedalusnetworks.priv> References: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com> <20050508213407.GA2150@gothmog.gr> <20050509102102.GA58668@fw.farid-hajji.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050509102102.GA58668@fw.farid-hajji.net> cc: freebsd-questions@freebsd.org cc: Fafa Hafiz Krantz Subject: Re: On removing ^M X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2005 10:30:13 -0000 On 2005-05-09 12:21, cpghost 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 :-)