Stewart Stremler wrote:

begin  quoting Todd Walton as of Wed, Jan 18, 2006 at 07:15:44PM -0800:
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?

Dash 'e', space, quote, your subsitution, quote, blah, blah, blah.

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.

Things in brackets are optional.... so yes, if no input file, stdin
will be used.
% sed -e 's/hello/world/'
hello
world
^D
%

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?

90% of the time, I use 's/string/otherstring/'; 90% of the rest of the
time I use '/pattern/d' to delete lines that match the specified pattern.

                       I think maybe s/// is all I need for my
purposes, though.  Do I just stick it in here?

Yup. In single-quotes, generally.

What am I doing???  Gawd don't make me have to use 'info'.

-e says the next argument is an edit command.  You can have more than
one of these (if you only have one, it's optional, but if you rely on
that you'll end up being stuck the next time you want to do *two*
edits).

/me compares Linux and Solaris manpages for sed

Oh, no wonder you're having a problem.  The Linux manpage for sed sucks!
(At least on the machine I'm checking it on.)

If you're planning much work with sed, the O'Reiley(?) book on sed (and the one on regular expressions) would be valuable.

DLK


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

Reply via email to