[geeks] ksh for loop question

doctor obnox son of a bitch drobnox at visi.com
Sat May 11 22:48:22 CDT 2002


On Sat, May 11, 2002 at 03:01:46PM -0400, Greg A. Woods had the audacity to opine:
> [ On Saturday, May 11, 2002 at 13:24:09 (-0500), doctor obnox son of a bitch wrote: ]
> > Subject: Re: [geeks] ksh for loop question
> >
> >  I just posted the way I'd do it myself, while sitting at a prompt.
> > 
> > In such a circumstance, I could care less about efficiency and elegant
> > design...I just type stuff, see what the output is, hit command history,
> > add another step to the pipeline, and try again. Lather, rinse, repeat,
> > until I get what I want. As long as it works, I'm okay.
> 
> You must really love using and re-using your command-line editing features!  ;-)
> 
 I do.
 That's what I was trying to say.
 I'm glad you understood. It shows me that I can write clearly in the
 english laguage.


> This isn't only about efficiency -- you were giving an example to
> someone who was trying to learn something, and you were doing it in a
> rather public forum that's publicly archived and publicly searchable.
 
 I was "doing it in a rather public forum". Cool. That's kinky. my wife
 would like that.

> If you think you can do that then you should teach them (and all the
> others who will vicariously learn from you) in the very best way you
> know how to.  The extraneous CLI noise makes your example almost twice
> as complex as it needed to be and as such even without the syntax errors
> was a rather poor example (though the core idea, if it hadn't been
> hidden in amongst so much chaff, is very good:  create a new shell
> script by manipulating the list of files into a list of commands and
> then feed them directly to the shell for execution).  I.e. write your
> examples as if you're writing a production quality shell script (though
> you might trim out all the extra error checking and other stuff that's
> there only for robustness, if you think it hides the central idea too
> much).
> 

 "Extraneous CLI noise" figures importantly in my way of working.
 A good core idea, even "hidden among so much chaff", is still a good
 core idea. My command line three commands and two pipes. that's "so
 much chaff"? I agree, the syntax error made it a poor example, but
 where's the chaff in the core idea, which you admit is "very good"?

> Maybe Unix 'cat' should require you to use I/O re-direction the same way
> MS-DOS 'type' does....  That'd learn ya!  :-)  (or maybe it wouldn't....)

 unix 'cat' will pipe the contents of a file to standard output. That's
 what I wanted to do. It's efficient from my point of view. One types
 'cat', then the filename. Maybe the underlying mechanics are repugnant
 to you, but it works.

> 
> (You do realize that you can put filenames on awk's command-line along
> with the first parameter being the awk program itself, don't you?  You
> do realize that awk will work just like cat when given a basic "wild-card"
> pattern and no action, don't you?  Eg.:  'awk /./ somefile anotherfile',
> is for all intents and purposes identical to 'cat somefile anotherfile'.)

 True. There are always more than one way to do something. I stipulate
 there may be a more effective way to do it. I pick the way that works
 for me. I have no fear of looking like a fool. 

> 
> (on some unix systems the pipe throughput even seems as slow as it is on
> MS-DOS (where it's implemented with temporary files and I/O redirection,
> due of course to the inherently single-tasking nature of Mickey-Soft))
> 

 If I noticed a slowness in pipe thopughput on the systems I worked on,
 I'd probably find another way to do it.

 I do things the New Jersey way: "good enough until proven otherwise".
 I'll acheive zenlike shell minimalist perfection someday. Until then,
 I'll get some work done.


-- 
Here's that flapjack                      ........Eric J. Gustafson
Put it in your pocket, 'til I get back    .........................
Goin' downtown, to see a man              .........................
Ain't got time to shake your hand         .........drobnox at visi.com



More information about the geeks mailing list