On Mon, Mar 25, 2002 at 05:05:39PM +0000, Padraig Brady wrote:
> Why?
>> sed -n -e "/[0-9]/p" testfile
>> is the same as:
>> grep "[0-9]" testfile
no it's not if the file args are testfile1 and testfile2. and that's a
good thing because if i'm editing files i don't want prefixes on the lines
i'm playing with. however for your example, they're both the same as:
awk '/[0-9]/{print}' testfile
or
perl -ne '/[0-9]/ && print' testfile
or
while read l; do case "$l"; in *[0-9]*) echo "$l" ;; esac; done < testfile
so should we roll the functionality of awk, perl and shell into sed?
and you ignored my comment about complexity. to do a simple search you
required two flags, two slashes and a p command. that's insane.
plus i don't see any docs concerning sed's return codes and what they
mean - rather important in scripts that use grep.
> With a common function of finding a pattern.
sometimes. you can also have sed add a boilerplate license at the top
of each license file. no searching, just position. otoh, sometimes
you just want grep to say the pattern exists, not to print it:
if grep -l foo bar > /dev/null 2>&1; then
echo get a beer for foo
else
echo sing mournfully for foo
fi
> 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. The hard bit is understanding the regular
> expressions.
personally, i like anything that reduces typing.
kevin
--
kevin at suberic.net buffy: come on, can't you put your foot down?!
fork()'ed on 37058400 giles: it *is* down.
meatspace place: orbit buffy: one of these days you're going to have to
http://suberic.net/~kevin get a grown up car. --inca mummy girl
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!