Date: Tue, 24 Sep 1996 00:15:08 -0700 (PDT) From: "Bryan K. Ogawa" <bkogawa@primenet.com> To: randyd@nconnect.net Cc: questions@freebsd.org Subject: Re: MS-DOS text files in UNIX Message-ID: <199609240715.AAA21496@foo.netvoyage.net> References: <324754C2.41C67EA6@nconnect.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <bkogawa@primenet.com> http://www.primenet.com/~bkogawa/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609240715.AAA21496>