[colug-432] complicated CLI pipelines (Re: Nice Plain Text Columns and Avoiding NIH: expand: not)

Jeff Frontz jeff.frontz at gmail.com
Mon Aug 29 13:14:17 EDT 2011


On Mon, Aug 29, 2011 at 12:51 PM, Stephen Potter <spp at unixsa.net> wrote:
> But, for CLI usage, how often do you really do
> more than two commands?


It depends-- my shell scripts often start out (or remain) as
abominations that I type by hand (and then use my HISTSIZE=5000
history file in conjunction with command-line editing to
refine/recall).

Take this one plucked from my history file (that I truly did type in,
although over several refinements):

for x in $(unzip -l /tmp/calibrate.zip | grep 08- |
        awk '{print $NF }')
        do
        [ -f $x.py ] && addisrc mr=OBIS100682 dir=software/src/aps srf=$x.py
        done

I'm not a big subscriber to "cat" over redirect, except in the case
where I have no idea how many arguments I'll be dealing with.  If I'm
really concerned with making sure that someone knows where the input
is coming from, I'll put the redirect first (a la:

       $ < /dev/null cat > emptyFile  # actually, would have used " >
emptyFile", but you get the point

And an affirmation of Rob's point about efficiency-- CPU, disk I/O,
and network bandwidth are not the only resources to worry about.
Often the most important resource is sitting in front of the keyboard,
trying to debug something in the middle of the night when production
machines are collapsing all around.  If it takes half an hour to
understand a clever hack before you can get the system back up, was it
really worth saving that minute or two of CPU time over the course of
a year?


Jeff



More information about the colug-432 mailing list