On Thu, 01 Jun 2006 18:54:09 +1200
Barry <[EMAIL PROTECTED]> wrote:

> 
> 
> Christopher Sawtell wrote:
> > On Thursday 01 June 2006 17:09, Barry wrote:
> > 
> >>Hi
> >>
> >>I want to parse a text file and replace a quoted expression with a 2nd
> >>expression.(actually a blank) I guess sed is the utility to use but what
> >>is the syntax please
> > 
> > [EMAIL PROTECTED] ~ $ echo '"change this"' | sed -e 's/\"change this\"/to 
> > that/'
> > to that
> > 
> > man sed
> > 
> > for the whole story.
> > 
> > --
> > CS
> 
> I need a filename in the command somewhere, also possibly an output file?
> 
> I looked at the man and info pages and gave up. IMO utter confusion for 
> someone who has never used the utility before and the 'examples' are no 
> help at all
> 
> Barry
> 

Barry it is called STREAM editor because it works on a stream, and a
stream flows through pipes and is often redirected. In geek talk it
translates between standard in and standard out. So you need to get the
input from stdin (easiest although not most efficient way is to use
cat) and redirect stdout to your output file. The usual way to do that
is with > or if you want to add it to the end of the output file use >>

 eg

cat inputfile|sed -e 's/find this/replace with this/g' > outputfile

translated

cocatenate (or join) inputfile to stdout. Feed stdout to a pipe | take
the other end of the pipe and attach it to sed. Get sed to replace
every occurrence (g) of "find this" with "replace with this" and feed
the result into another pipe |. Take the other end of that second pipe
and instead of spraying it all over the screen redirect (>) it to the
file outputfile. 

Reply via email to