Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!intelca!mipos3!cadev4!pinkas From: pinkas@cadev4.intel.com (Israel Pinkas ~) Newsgroups: comp.unix.questions Subject: Re: Finding Files Message-ID: <1442@mipos3.intel.com> Date: 10 Dec 87 01:15:57 GMT References: <205700003@prism> Sender: nobody@mipos3.intel.com Reply-To: pinkas@cadev4.UUCP (Israel Pinkas ~) Organization: Corporate CAD, INTeL Corporation, Santa Clara, CA Lines: 57 In article <205700003@prism> billc@prism.UUCP writes: > > Right now, to find a file somewhere under my current directory, > I use the following alias: > > alias where "find \$cwd -name \!* -exec echo {} \;" > > Question: Is there a better way to do this? Try: alias where 'find . -name \!!:1 -print' There are a few problems with the alias: 1) csh guarantees to expand all variables inside double quotes. Thus, cwd is expanded at alias definition time. For example: echo "\$mail" returns \/usr/spool/mail/pinkas 2) $cwd is not an acurate reresentation of the current directory. Consider what happens when you cd to a symbolic link which points to a directory. $cwd is set to the name of the symbolic link. Now, if you type 'cd ..', `pwd` and $cwd return two vastly different things. I take care of this by aliasing every command that might result in a directory change to execute an alias called sprompt, which has a side effect of setting cwd correctly. 3) \!* will return all the arguments given to the alias. If more than one is given, this will result in bad parameters to find. 4) -print is more efficient than forking a shell to execute echo. Has the same result. The alias that I gave is one that I use for the csh class that I teach internally. About 20-30 of my students have let me know that they use it all the time. -Israel ---------------------------------------------------------------------- Disclaimer: The above are my personal opinions, and in no way represent the opinions of Intel Corporation. In no way should the above be taken to be a statement of Intel. UUCP: {amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!cadev4!pinkas ARPA: pinkas%cadev4.intel.com@relay.cs.net CSNET: pinkas%cadev4.intel.com --------- "You can do more with a kind word and a gun than with just a kind word" -Al Capone