[mdlug] UNIX tips: Learn 10 good UNIX usage habits

Michael Corral micorral at comcast.net
Mon Mar 10 05:37:22 EDT 2008


2008-03-10, Monsieur Robert Citek a ecrit:
> But my point was about not taking that rule (or any of the rules) as
> dogma.  Sometimes maintaining a pattern is more important than
> execution efficiency. In many cases, I find the pattern "$prog1
> $files | $prog2" easier and more consistent to work with.  So I'll use
> it, regardless if $prog1 is cat or if $files expands to only one file.

Well, that pattern can get you into trouble. For example, do this
in bash:

x=hello
echo "goodbye" | read x
echo "${x}"

While I wouldn't make a "dogma" of not calling cat, neither would I
make a fetish of that "pattern" you like so much.

> Besides, if I'm worrying about execution efficiency, I should probably
> be writing the program in C and not in shell.

So efficiency of shell scripts doesn't matter? I think there are a lot
of sysadmins (and their bosses) who would disagree with that.

By that argument, you should write the program in assembly language,
not C. The point is, you should strive for efficiency no matter what
language is used. In the vast majority of cases, calling cat is not
efficient.

Michael



More information about the mdlug mailing list