On 1/18/06, Todd Walton <[EMAIL PROTECTED]> wrote:
> So.  Back to sed.  I was hoping for a conceptual overview of the
> different parts of a sed command line.  The man page says:
>
> "sed [OPTION]... {script-only-if-no-other-script} [input-file]..."
>
> So, we have the command, 'sed'.  Then options to sed.  Then... what?
> And the file we're performing the operation on.  Presumably the file
> is optional, and stdin is okay.  It occurred to me a while ago that my
> "Linux in a Nutshell" book has a whole section on sed (and awk) but I
> can't seem to find it.
>
> I'm guessing that script-only-blah part is where I put the edits to
> perform.  These edits come in the form of options? (dash-something)  I
> know for sure that sed does the s/// substitute, but most edits don't
> look like that, right?  I think maybe s/// is all I need for my
> purposes, though.  Do I just stick it in here?

OK.  Here is the simple one-liner example of using sed to make a substitution:
- - - - - -
[EMAIL PROTECTED] cat text
one
two
three
four
two again
[EMAIL PROTECTED] sed 's/two/TWO/' text
one
TWO
three
four
TWO again
- - - - - -

As usual, there are lots of other things you can do.  If you are
serious about using classical always-available Unix tools you should
try to get a copy of _Tke Unix Programming Environment_, Kernighan &
Pike, ISBN 0-13-937681-X.  It is 21 years old by now, but chock full
of useful information.  The sub-chapter on sed is only about 5 pages
long but it tells you pretty much all a normal person needs to know.

You won't learn how to write a net-news reader or a program that plays
Towers of Hanoi, however.  I just checked AddAll book search, new
paperback copies can be bought for prices that range from $5 to $50. 
Used hardback copies can be bought for $15 and up.
Buy the book!!

    carl
--
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to