From owner-freebsd-questions@FreeBSD.ORG Mon May 9 10:23:17 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 A717316A4E7 for ; Mon, 9 May 2005 10:23:17 +0000 (GMT) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 27D5043D6D for ; Mon, 9 May 2005 10:23:17 +0000 (GMT) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (net4801-2 [192.168.254.1]) by fw.farid-hajji.net (Postfix) with ESMTP id 375394B21E; Mon, 9 May 2005 12:21:02 +0200 (CEST) Date: Mon, 9 May 2005 12:21:02 +0200 From: cpghost To: Giorgos Keramidas Message-ID: <20050509102102.GA58668@fw.farid-hajji.net> References: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com> <20050508213407.GA2150@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050508213407.GA2150@gothmog.gr> User-Agent: Mutt/1.5.8i 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:23:17 -0000 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 Regards, -cpghost. -- Cordula's Web. http://www.cordula.ws/