Skip to content

Instantly share code, notes, and snippets.

@mustpax
Created March 9, 2010 22:36
Show Gist options
  • Save mustpax/327229 to your computer and use it in GitHub Desktop.
Save mustpax/327229 to your computer and use it in GitHub Desktop.
Find file, cd to parent directory
function cdto {
local targetfile;
local searchdir;
if [ -z "$2" ]; then
searchdir=.
targetfile=$1
else
searchdir=$1
targetfile=$2
fi;
echo searchdir: $searchdir target: $targetfile
pushd `find $searchdir -iname "$targetfile*" -type f -exec dirname {} \; -quit`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment