Skip to content

Instantly share code, notes, and snippets.

@sterling
Last active April 29, 2017 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sterling/a3ec550f04f75f821a083e4e09fba991 to your computer and use it in GitHub Desktop.
Save sterling/a3ec550f04f75f821a083e4e09fba991 to your computer and use it in GitHub Desktop.
Recursively find a child directory
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