From owner-freebsd-questions@FreeBSD.ORG Sun May 8 21:34:22 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 2F28D16A4E6 for ; Sun, 8 May 2005 21:34:22 +0000 (GMT) Received: from nic.ach.sch.gr (nic.sch.gr [194.63.238.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D5E743DB7 for ; Sun, 8 May 2005 21:34:17 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: (qmail 13444 invoked by uid 207); 8 May 2005 21:34:15 -0000 Received: from keramida@ceid.upatras.gr by nic by uid 201 with qmail-scanner-1.21 (sophie: 3.04/2.19/3.81. Clear:RC:1(81.186.70.229):. Processed in 0.382483 secs); 08 May 2005 21:34:15 -0000 Received: from dialup229.ach.sch.gr (HELO gothmog.gr) ([81.186.70.229]) (envelope-sender ) by nic.sch.gr (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 8 May 2005 21:34:14 -0000 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.3/8.13.3) with ESMTP id j48LY8RW002216; Mon, 9 May 2005 00:34:08 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.3/8.13.3/Submit) id j48LY8XK002215; Mon, 9 May 2005 00:34:08 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 9 May 2005 00:34:08 +0300 From: Giorgos Keramidas To: Fafa Hafiz Krantz Message-ID: <20050508213407.GA2150@gothmog.gr> References: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com> cc: freebsd-questions@freebsd.org 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: Sun, 08 May 2005 21:34:22 -0000 On 2005-05-08 14:20, Fafa Hafiz Krantz wrote: > > Good day all! > > I am aware of the port unix2dos (dos2unix) as a tool to > remove ^Ms from ASCII files. > > But if you execute dos2unix in a directory where some files > contain ^M (CR/LF) and some files don't (CR), then dos2unix > will make a mess of those files who don't. > > I am wondering what is needed (what tool or what code) to > do a mass (recursive) removal of ^Ms? 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