Last active
April 29, 2017 16:47
-
-
Save sterling/a3ec550f04f75f821a083e4e09fba991 to your computer and use it in GitHub Desktop.
Recursively find a child directory
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
go () { | |
GO="" | |
for dir in /webhome; do | |
for d in {1..3}; do | |
D="`find $dir -type d -maxdepth $d -iname "$1"|head -n1`" | |
if [ -n "$D" ]; then | |
GO=$D | |
break 2 | |
fi | |
done; | |
done; | |
if [ -n "$GO" ]; then | |
cd $GO | |
else | |
echo "unable to find $1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment