#
| Date: Mon, 25 Mar 2002 17:05:39 +0000
| From: Padraig Brady <padraig at antefacto.com>
|[ ... ]
| sed -n -e "/[0-9]/p" testfile
|
| is the same as:
|
| grep "[0-9]" testfile
and:
ed testfile
g/[0-9]/p
q
is a superset of both; ergo, by this logic,
_both_ grep and sed are superfluous.
superset because, e.g., ed can "go backwards"
in a file, whilst neither sed nor grep can.
hence, as an example, the previous challenge
of `grep -C5 re file' can be done as:
ed file
g/re/.-5,.+5p
q
however, if you've ever tried to use ed in
a pipeline (e.g.), you'll probably quickly
appreciate why sed came to be.
as noted previously, both sed and grep were
originally derived from the more general ed.
so the argument seems to be they "shouldn't"
have been derived --- or even necessary? ---
in the first place. that seems to be an
unsupportable proposition, as it appears
to deny that specialist tools (e.g. hammers)
are needed when a general solution can be
used (e.g. rocks).
|[ ... ]
| I think it's as easy for someone to learn the p command
| in sed, as a seperate grep command. That just takes a
| minute or two. [ ... ]
<IMHO>
whilst I question the example stated, there
is a similar example along those lines which
seems to have some validity:
head -20 file
is the same as:
sed 20q file
the "ease of typing" argument doesn't apply to
this example; and the "overhead" counter-argument
is problematic.
</IMHO>
cheers!
-blf-
--
Innovative, very experienced, Unix and | Brian Foster Dublin, Ireland
Chorus (embedded RTOS) kernel internals | e-mail: blf at utvinternet.ie
expert looking for a new position ... | mobile: (+353 or 0)86 854 9268
For a resume, contact me, or see my website http://www.blf.utvinternet.ie
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!