Skip to content

Instantly share code, notes, and snippets.

@scwood
Last active June 2, 2017 18:38
Show Gist options
  • Select an option

  • Save scwood/d0fc7576c8cac37fde1a6b6c39ade808 to your computer and use it in GitHub Desktop.

Select an option

Save scwood/d0fc7576c8cac37fde1a6b6c39ade808 to your computer and use it in GitHub Desktop.
Using find to only get files in nested directories n levels deep
# So here's my directory structure
# .
# ├── a
# │   └── test.sh
# ├── b
# │   └── test.sh
# └── test.sh
find . -name *.sh
# ./a/test.sh
# ./b/test.sh
# ./test.sh
find ./*/* -name '*.sh'
# ./a/test.sh
# ./b/test.sh
# So if you only wanted files that were three directories deep, you would do ./*/*/* etc.
# Make sense?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment