[net.unix] Interesting Bourne shell usage

honey@down.UUCP (05/13/84)

the sadly missed feature (i.e., requisite) in csh is a parser.
	peter honeyman

dave@utcsrgv.UUCP (Dave Sherman) (05/22/84)

Recently I have gotten to like using the Bourne shell for programming
on the fly - not even creating a shell file, as I did in days of old.
Today I was revising a software package in a "test" subdirectory, and
wanted a quick list of all the diffs. Then I thought I might like to
save a copy. I tried the following, and to my surprise, it worked:

$ for i in *.c
> do
> echo $i:
> echo
> diff $i ../$i
> echo
> done ^ tee junk


It was the pipe at the end that worked "to my surprise". I guess it
makes sense, since the "for" is all one command, but it was kind of unusual.

Dave Sherman
Toronto
-- 

 dave at Toronto (CSnet)
 {allegra,cornell,decvax,ihnp4,linus,utzoo}!utcsrgv!dave

thomas@utah-gr.UUCP (05/24/84)

The ability of the Bourne shell to do I/O redirection on its "composite"
commands is a nice feature, sadly missing from the Csh.

=S

rpw3@fortune.UUCP (05/31/84)

#R:utcsrgv:-436400:fortune:26900060:000:644
fortune!rpw3    May 30 21:10:00 1984

Inspired by the "pick" command in Kernighan & Pike's book, I tried:

	$ for i in `find . -name '*foo*' -print`
	> do echo -n "${i}? "
	> read ans
	> eval $ans
	> done

This allows you to execute a different command on each file found,
or execute a command that uses the file (referenced as $i) more
than once in the command (which find's -exec doesn't let you do).
Just <CR> if you don't want to do anything to one of them.

Hack, Hack... but useful when you need it.

Rob Warnock

UUCP:	{ihnp4,ucbvax!amd70,hpda,harpo,sri-unix,allegra}!fortune!rpw3
DDD:	(415)595-8444
USPS:	Fortune Systems Corp, 101 Twin Dolphin Drive, Redwood City, CA 94065