Path: utzoo!mnetor!uunet!aimt!breck From: breck@aimt.UUCP (Robert Breckinridge Beatie) Newsgroups: comp.unix.questions Subject: Re: Finding Files Message-ID: <377@aimt.UUCP> Date: 14 Dec 87 05:04:49 GMT References: <205700003@prism> <1442@mipos3.intel.com> Organization: AIM Technology, Palo Alto, CA Lines: 47 In article <1442@mipos3.intel.com>, pinkas@cadev4.intel.com (Israel Pinkas ~) writes: > In article <205700003@prism> billc@prism.UUCP writes: > > I use the following alias: > > alias where "find \$cwd -name \!* -exec echo {} \;" > > Question: Is there a better way to do this? > > alias where 'find . -name \!!:1 -print' > > There are a few problems with the alias: > > 3) \!* will return all the arguments given to the alias. If more than one > is given, this will result in bad parameters to find. Well, here's a small improvement with which I was inordinately pleased: alias where 'set noglob ; find . `namepred \!*` -print ; unset noglob' Here is the source for namepred: main(argc,argv) int argc; char **argv; { if(--argc <= 0) exit(0); printf("( "); do { printf("-name %s ",*++argv); } while (--argc > 0 && (printf("-o ") || 1)); printf(")\n"); } it expands its argument list into: ( -name arg1 -o -name arg2 -o ... -o -name argn ) which find can deal with. The "set noglob" keeps csh from expanding metacharacters in the output of namepred. This allows things like: where '*file*' to match files with, "file" as part of their name. Like I say, I'm probably more pleased with this than I should be... but what the heck. -- Breck Beatie {uunet,pyramid!weitek}!aimt!breck "Sloppy as hell Little Father. You've embarassed me no end."