[H-CHAT] Re: [H-GEN] Encrypting a tar backup

Jason Parker-Burlingham jasonp at uq.net.au
Thu Oct 24 11:15:36 EDT 2002


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

Greg Black <gjb at gbch.net> writes:

> Well, the pedants would say that example 2 should be:
>     $ program < file

Yes, for exactly equivalent operation, that's true.  However except
for broken (FSVO) tools, it'll do.

> |         $ WRONG=`cat file | grep pattern | wc -l`
> |         $ RIGHT=$(grep -c pattern file)
> Here again, I would disagree.  It's not grep's job to count
> stuff and that's better left to the specialised program, wc.

This is where I started to think there may be something interesting
going on.  I think that you and I use two quite different sets of
idioms when shell programming.  I prefer to use all the options
available to me, regardless of whether they really match the program's
stated purpose, while (and I hesitate to try to summarize your point
of view) you seem to have distinct expectations of the duties of each
program.  I'm sure there are list members who sort into either camp.

Perhaps a good discriminator would be whether one would use sort -u?

> Part of learning about shell programming (and command line use in
> general) is understanding when you might want to use cat and when
> you're better off not using it.[2]

And I think this is the point I was trying to make.  Your earlier
example was a case that I had missed.

> There are far
> more important things to weed out of one's repertoire.

Especially if the poor sap is using C shell for scripting!

(Actually, a confusion between reading from STDIN and using the ``
operator springs to mind.  I've seen that one a lot, and explaining it
can get a little tricky.)

jason
-- 
||----|---|------------|--|-------|------|-----------|-#---|-|--|------||
| ``It's just a big electric typewriter.''                              |
|                                                                       |
||--|--------|--------------|----|-------------|------|---------|-----|-|

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list