🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.misc
4 messages
4 total messages Started by Melvin Wilson Tue, 04 Aug 1992 02:45
filtering a text file
#669
Author: Melvin Wilson
Date: Tue, 04 Aug 1992 02:45
13 lines
950 bytes
Hello,

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 I  
cannot figure out the apropriate format of the command.

--------------------------------------------------------------------
Melman@uiuc.edi                                     Melvin Wilson Jr.
                          University of Illinois at Urbana-Champaign
Re: filtering a text file
#679
Author: Tom Marchioro
Date: Tue, 04 Aug 1992 15:38
48 lines
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
Re: filtering a text file
#786
Author: Volker Herminghaus-Shirai
Date: Thu, 06 Aug 1992 10:29
26 lines
1438 bytes
In article <BsFuBt.D8I@news.cso.uiuc.edu> Melman@uiuc.edu (Melvin Wilson)  
writes:
> Hello,
> 
> 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  
I  
> cannot figure out the apropriate format of the command.

type
	<inputfile >outputfile sed 's/old/new/g'
replacing inputfile and outputfile with their respective values.
The expression "old" will be replaced by "new". If old or new contain
any / characters, use a different character in the sed expression instead, like
	sed 's:old:new:g'

--
Volker Herminghaus-Shirai (vhs@darkcube.radig.de)

Computer industry: Industry in which the number of units sold of any
given product is inversely proportional to its technical excellence.
See also: MS-DOS, Windows, IBM-PC, X, QWERTY, 80x86.
Re: filtering a text file
#803
Author: Mark Neidengard
Date: Thu, 06 Aug 1992 20:54
41 lines
1937 bytes
In article <1992Aug6.102953.8775@darkcube.radig.de> vhs@darkcube.radig.de writes:
>In article <BsFuBt.D8I@news.cso.uiuc.edu> Melman@uiuc.edu (Melvin Wilson)  
>writes:
>> Hello,
>> 
>> 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  
>I  
>> cannot figure out the apropriate format of the command.
>
>type
>	<inputfile >outputfile sed 's/old/new/g'
>replacing inputfile and outputfile with their respective values.
>The expression "old" will be replaced by "new". If old or new contain
>any / characters, use a different character in the sed expression instead, like
>	sed 's:old:new:g'
>
>--
>Volker Herminghaus-Shirai (vhs@darkcube.radig.de)
>
>Computer industry: Industry in which the number of units sold of any
>given product is inversely proportional to its technical excellence.
>See also: MS-DOS, Windows, IBM-PC, X, QWERTY, 80x86.

The easy way to REMOVE things using sed is to replace them by a null.

This is accomplished by saying:

'cat oldfile | sed s/searchstring//g > outputfile'

This will QUICKLY remove every instance of your searchstring by replacing it
with NOTHING =)

Have fun!

Mark Neidengard
mneideng@cosmos.aca.calpoly.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads