Skip to content

Instantly share code, notes, and snippets.

@jeffreyroberts
Created April 17, 2013 18:58
Show Gist options
  • Save jeffreyroberts/5406798 to your computer and use it in GitHub Desktop.
Save jeffreyroberts/5406798 to your computer and use it in GitHub Desktop.
Bash Resolve Sub Directories
resolve_sub_dirs() {
path=""
path_arg="$1"
search="$path_arg/sub-"*
for command in $search; do
if [ -d "$command" ]; then
if [ "$path" != "" ]; then
path="$command:$path"
else
path="$command"
fi
dir_paths="$(resolve_sub_dirs $command)"
if [ "$dir_paths" != "" ]; then
path="$dir_paths:$path"
fi
fi
done
echo $path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment