Date: Mon, 9 May 2005 00:34:08 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Fafa Hafiz Krantz <fteg@london.com> Cc: freebsd-questions@freebsd.org Subject: Re: On removing ^M Message-ID: <20050508213407.GA2150@gothmog.gr> In-Reply-To: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com> References: <20050508192019.127ED1CE303@ws1-6.us4.outblaze.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-05-08 14:20, Fafa Hafiz Krantz <fteg@london.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050508213407.GA2150>