Search code examples
bashcommanddirectory-traversal

Perform an action in every sub-directory using Bash


I am working on a script that needs to perform an action in every sub-directory of a specific folder.

What is the most efficient way to write that?


Solution

  • for D in $(find . -mindepth 1 -maxdepth 1 -type d); do
        //Do whatever you need with D
    done