[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: sed -n vs. sed



William Ballard wrote:
> What semantically huge iceberg of a use case am I missing that makes 
> "sed -n" useful?

Try this:

  sed -n '/PATH/p' /etc/profile

Compare that to the version without -n.  There are many times where I
don't want the default action to be print.  If I were to think of it a
little more I could come up with real examples of using it.

  sed -n '/^+/q;p' /etc/passwd
  sed -n '/^+/,$p' /etc/passwd

[NIS/YP uses a line with a '+' to denote pulling in the mapfile right
there in the middle of the file.]

Bob

Attachment: pgpdYys52ogVz.pgp
Description: PGP signature


Reply to: