Help with this script

Paul Chamberlain tif at doorstop.austin.ibm.com
Fri Apr 12 02:25:11 AEST 1991


In article <560 at racerx.UUCP> ken at racerx.UUCP (Ken Hardy) writes:
>>	cd `find . -name <argument> -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



More information about the Comp.unix.shell mailing list