[geeks] ksh for loop question

Greg A. Woods woods at weird.com
Sat May 11 14:01:46 CDT 2002


[ 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!  ;-)

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.
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).

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....)

(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'.)

(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))

-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods at acm.org>;  <g.a.woods at ieee.org>;  <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>



More information about the geeks mailing list