Created
March 9, 2010 22:36
-
-
Save mustpax/327229 to your computer and use it in GitHub Desktop.
Find file, cd to parent directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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