Created
April 17, 2013 18:58
-
-
Save jeffreyroberts/5406798 to your computer and use it in GitHub Desktop.
Bash Resolve Sub 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
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