Article View: comp.sys.next.misc
Article #679Re: filtering a text file
From: Tom Marchioro
Date: Tue, 04 Aug 1992 15:38
Date: Tue, 04 Aug 1992 15:38
48 lines
2049 bytes
2049 bytes
Melman@uiuc.edu (Melvin Wilson) writes: : Help! : : I have a very simple (and for the more experienced, stupid) question. : : From the command prompt on a NeXT how could I search a text file and remove : every instance of a particular expression in that text file? I've tried but : cannot figure out the apropriate format of the command. : the two ways that come immediately to mind are to use the Unix batch editor, called "sed" and its -d option to remove multicharacter expressions. See the man pages for sed (or any good Unix book). If all you want to do is to remove a particular character (such as the infamous ^M s which come from DOS files, then it's probably even easier to use the Unix command "tr" (for "translate characters", see the man pages for tr) and it's -d option to eliminate the characters. For example, if you have a file called testfile wiht ^M s in it >>>>>>tesfile<<<<<<<< The rain in spain falls mainly on the plain.^M The rain in spain falls mainly down the drain.^M then the command tr -d '\015' <testfile >outfile will remove the ^M s (which have character code \015) >>>>>>>outfile<<<<<<<<<<< The rain in spain falls mainly on the plain. The rain in spain falls mainly down the drain. Again, see the man pages for whichever is appropriate or drop me a note containing the specific example. (Personal opinion: "sed" is like a microwave, i.e. it's one of those things you can get through life easily without, but once you have learned about it your life is much better). Hope this is Helpful tom
Technical Details
Message-ID:
<1992Aug4.153817.1457@maccs.dcss.mcmaster.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!maccs!nextasy!tlmReferences:
<BsFuBt.D8I@news.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.misc Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!maccs!nextasy!tlm From: tlm@nextasy.physics.mcmaster.ca (Tom Marchioro) Subject: Re: filtering a text file Message-ID: <1992Aug4.153817.1457@maccs.dcss.mcmaster.ca> Sender: news@maccs.dcss.mcmaster.ca (News account) Organization: McMaster University, Hamilton, Ontario, Canada. References: <BsFuBt.D8I@news.cso.uiuc.edu> Date: Tue, 4 Aug 1992 15:38:17 GMT Lines: 51