LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author] [stats]
  From: David Newall <davidn@rebel.net.au>
  To  : Andrew Reid <andrew.reid@plug.cx>
  Date: Wed, 30 May 2001 15:34:48 +0930 (CST)

Re: Bash and Vi Mode

> "Beauty is in the eye of the beholder"

Normally I would agree, but in this case, no, it's not a question of
beauty, or different but equally good ways of performing the same task.
This is a case of constructing a pipeline when you don't need to.
It's a case of using cat to feed a file to grep when grep is perfectly
capable of reading the file for itself.  In my mind it's less clear than
the simple grep, because you have to think about two commands (cat and
grep) instead of one; and without any doubt it's less efficient because
it read the file, writes it, and then reads it again.

Pipes are wonderful, but don't for one minute believe they have no cost.
Comprehension and performance can both suffer from their needless use.
Otherwise we always say:

  cat file | tac | cat | tac | cat - | tac | grep pattern | tac | cat


This is, of course, identical to "grep pattern file" for most patterns,
but it's hardly neat.

-- 
LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
  mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author] [stats]
Return to the LinuxSA Mailing List Information Page