Created
January 7, 2016 05:34
-
-
Save blockloop/353770cec31f5b82a8a7 to your computer and use it in GitHub Desktop.
Search upward to find a certain file or directory. I don't know where I found this or if I wrote it myself.
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
upsearch() { | |
origdir=${2-$(pwd)} | |
test / == "$PWD" && cd "$origdir" && return || \ | |
test -e "$1" && echo "$PWD" && cd "$origdir" && return || \ | |
cd .. && upsearch "$1" "$origdir" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment