In comp.os.linux.advocacy, Roy Schestowitz
on Wed, 03 May 2006 11:29:59 +0100
> __/ [ Tim Smith ] on Wednesday 03 May 2006 04:04 \__
>> In article <618li3-e0o.ln1@xxxxxxxxxxxxxxxxxxxxxxx>,
>> The Ghost In The Machine <ewill@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>> > Can grep return just the word that matches the pattern, or can it only
>>> > return the whole line?
>>> For details on any of these, 'man grep', 'man sed', or
>>> 'man bash' (as bash handles the redirects).
>> One thing to keep in mind, though. If you need to do anything that you
>> can't very quickly see how to do in grep or sed or whatever, then it
>> often will be faster to write a little Perl script, rather than dig
>> through the zillion options of grep, etc., trying to find the
>> combination that does what you want.
> Au comtraire. In defence of grep, its basic use is simple enough to appeal to
> command-line newbies:
> grep file 'search phrase' (or regular expression, if you must)
> This is quicker to do than opening a file, opening search prompt/widget, then
> entering phrase. Also, grep is less computationally hungry.
> Then come to consider extensibility, recursion, batch mode (including
> scriptability), and multi-file operations. When someone sought the code of
> an error message in WordPress, for example, I immediately ran:
> grep -r * 'error message substring'
> to find the line in a file within a subdirectory.
> That's not too complex, yet the level of expressiveness is high.
> Best wishes,
Yes, grep and sed do the simple stuff well enough; perl is for the more
complicated items. :-)
At least, that's my take, more or less.
Windows Vista. Because it's time to refresh your hardware. Trust us.