Created
March 22, 2023 07:57
-
-
Save pabsan-0/eba2c775e612b825330f9559c9198e0f to your computer and use it in GitHub Desktop.
Snippets to look for files in parent directories
This file contains 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
## https://unix.stackexchange.com/a/22215 | |
## find_up filename | |
find_up () { | |
path=$(pwd) | |
while [[ "$path" != "" && ! -e "$path/$1" ]]; do | |
path=${path%/*} | |
done | |
echo "$path" | |
} | |
## find_parent_ws | |
find_parent_ws () { | |
path=$(pwd) | |
while [[ "$path" != "" && ! -e "$path/.catkin_workspace" ]]; do | |
path=${path%/*} | |
done | |
echo "$path" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment