Skip to content

Instantly share code, notes, and snippets.

@pabsan-0
Created March 22, 2023 07:57
Show Gist options
  • Save pabsan-0/eba2c775e612b825330f9559c9198e0f to your computer and use it in GitHub Desktop.
Save pabsan-0/eba2c775e612b825330f9559c9198e0f to your computer and use it in GitHub Desktop.
Snippets to look for files in parent directories
## 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