From owner-freebsd-questions Thu Nov 8 14:16:51 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 6157C37B419 for ; Thu, 8 Nov 2001 14:16:44 -0800 (PST) Received: from hades.hell.gr (patr530-b234.otenet.gr [212.205.244.242]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id fA8MGdB25770; Fri, 9 Nov 2001 00:16:39 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id fA8LUHG00756; Thu, 8 Nov 2001 23:30:18 +0200 (EET) (envelope-from charon@labs.gr) Date: Thu, 8 Nov 2001 23:30:17 +0200 From: Giorgos Keramidas To: David Loszewski Cc: freebsd-questions@FreeBSD.ORG Subject: Re: ^M on end of lines Message-ID: <20011108233017.A548@hades.hell.gr> References: <169116798405.20011103214209@telus.net> <001a01c16508$e4623670$3000a8c0@sickness> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001a01c16508$e4623670$3000a8c0@sickness> User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Nov 04, 2001 at 03:15:40AM -0500, David Loszewski wrote: > How bout if I wanna do it directories at a time? Like a whole bunch of > directories? The second suggestion, using tr(1) to 'delete' the \015 character is easy to wrap in a script that does this automagically for you. In fact, a script that puts together the right tools to do your job is probably the best way to do this. You can filter all the files that match '^M' with a combination of find, grep and other standard FreeBSD tools. Hell you can even make an ex(1) script and do the equivalent of `editing the file' in a non-interactive way. Here's a sample session from a test I just did to convert a file called "hello.txt" from DOS format to Unix format. > cat -e hello.txt hello world^M$ > cat ~/scripts/dos2unix.ex %s/^M/g :wq > ex -c ":so dos2unix.ex" hello.txt hello.txt: 1 lines, 1 characters > cat -e hello.txt hello world$ > Since `editing' a file to remove ^M characters can be done with ex(1) and our simple dos2unix.ex script, and you have saved dos2unix.ex in your HOME/scripts directory (haven't you?) here's a command line that will convert all the *.txt files under ~/doc to Unix format: > find ~/doc -name '*.txt' |\ xargs -1 ex -c ":so $HOME/scripts/dos2unix.ex" And that's just one of a billion ways to do this. You can probably find easier and faster ways, or tools that will do everything you want without all this `scripting madness'. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message