Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime!doorstop.austin.ibm.com!tif From: tif@doorstop.austin.ibm.com (Paul Chamberlain) Newsgroups: comp.unix.shell Subject: Re: Help with this script Message-ID: <6587@awdprime.UUCP> Date: 11 Apr 91 16:25:11 GMT References: <1991Apr9.164257.9128@agate.berkeley.edu> <1991Apr9.175008.12044@leland.Stanford.EDU> <560@racerx.UUCP> Sender: news@awdprime.UUCP Reply-To: tif@doorstop.austin.ibm.com (Paul Chamberlain) Organization: IBM AWD, Austin Lines: 20 In article <560@racerx.UUCP> ken@racerx.UUCP (Ken Hardy) writes: >> cd `find . -name -type d -print` >If 'find' finds more than one directory that matches the pattern, >you're in trouble. If you do it this way, you'll either change directories and print the directory you went to, or get an error changing directories and display the list of directories found. The only time this is awkward is if one directory was found but the cd failed (i.e. mkdir x; chmod 0 x; fcd x). function fcd { typeset dirs dirs=`find . -name "*${1}*" -type d -print` cd $dirs echo $dirs | tr ' ' '\012' } Paul Chamberlain | I do NOT speak for IBM. IBM VNET: PAULCC AT AUSTIN 512/838-9748 | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif