From owner-freebsd-questions Tue Sep 24 00:15:18 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id AAA12972 for questions-outgoing; Tue, 24 Sep 1996 00:15:18 -0700 (PDT) Received: from foo.netvoyage.net (ip112.lax.primenet.com [204.212.59.112]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id AAA12935 for ; Tue, 24 Sep 1996 00:15:14 -0700 (PDT) Received: (from bkogawa@localhost) by foo.netvoyage.net (8.7.5/8.6.12) id AAA21496; Tue, 24 Sep 1996 00:15:08 -0700 (PDT) Date: Tue, 24 Sep 1996 00:15:08 -0700 (PDT) Message-Id: <199609240715.AAA21496@foo.netvoyage.net> To: randyd@nconnect.net Cc: questions@freebsd.org Subject: Re: MS-DOS text files in UNIX Newsgroups: localhost.freebsd.questions References: <324754C2.41C67EA6@nconnect.net> From: "Bryan K. Ogawa" X-Newsreader: NN version 6.5.0 #1 (NOV) Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In localhost.freebsd.questions you write: >Greetings, > I've read numerous things about adding the CR-LF back into text files >for use with DOS, but what about the other way?? Is there a way to >remove >that annoying ^M from a DOS text file under FBSD? I've tried many >things >but nothing short of removing them one-by-one seems to work. There's a classy sed technique for this, but I know perl better, so... ---- SNIP ---- #!/usr/bin/perl -ni.bak s/\r//g; print; ---- SNIP ---- This works with filenames. If you call that file ms2unix, then do a chmod a+x ms2unix , then you can run it like so: ./ms2unix file.txt and it'll strip ^M from file.txt . A backup with CRs is stored in file.txt.bak . The filter equivalent is: perl -ne 's/\r//g;print;' which should take stdin, kill CR, and pump to stdout. >Thanks >Randy -- bryan k ogawa http://www.primenet.com/~bkogawa/