[alt.sources] lsyn - query about dir entries, 'y' -> stdout

daniel@island.COM (Daniel Smith - coming soon to a file near you) (01/12/91)

	Note: This REQUIRES grabchars.  If you don't have this, get version
1.95 from comp.sources.misc archives worldwide, or directly from me
(the author :-).


	This is a quickie shell script I wrote to use when making
tar tapes or in other situations where I want a subset of files available.
It prompts you for each file, and all the files you answer 'y' to
(you can just hit return for the default) are echoed to stdout.  This
allows you to do things like:

	tar cvf /dev/rst8 `lsyn`

	...which can be more handy/quicker than trying to come up with the
right combination of *, ?. etc....depends on the directory.  Have fun!

				Daniel

[this is 24 lines exactly, might be easiest just to cut and paste]
---cut here ---------------------------
#! /bin/csh -f
#
#	lsyn - ask about each entry in a directory, yes answers go to stdout
#
#	daniel@island.com, January 1991
#
if ($#argv == 0) then
	set files=(*)
else
	set files=($argv[1-$#argv])
endif

set outfiles

while ($#files)
	set a=`grabchars -b -d y -c ynYN -L -r -q "do you want $files[1]? "`
	echo "" > /dev/tty
	if ($a =~ "y") then
		set outfiles=($outfiles $files[1])
	endif
	shift files
end
echo $outfiles | tr ' ' '\012'
---cut here ---------------------------

-- 
daniel@island.com       Daniel Smith, Island Graphics, (415) 491 0765 x 250(w)
daniel@world.std.com      4000 CivicCenterDrive SanRafael MarinCounty CA 94903
dansmith@well.sf.ca.us      Fax: 491 0402 Disclaimer: Hey, I wrote it, not IG!
Go get lunch.  Come back, plug in tape #2 and go to lunch again. -Mike Anderson