Create sub directories recursively - Bash script

Published on Sep 14, 2016 & tagged in Linux, Bash

In some situations, I want to create sub directories recursively. It is so simple in Bash. Assume that we have to create directory with name main.

for dir in */; do
  mkdir "$dir/main"
done

Remove sub directories recursively

for dir in */; do
  rm -rf "$dir/main"
done

Do you need any help on Linux & Bash?

I'm happy to help you. Just fill the form on contact page & I will get back to you within few hours.

Recent Posts

  1. The add_image_size() function - WordPress best practices
  2. Remove page title using filter - WordPress
  3. Comment out code in Liquid Template Language
  4. Remove Plugin Stylesheets and Scripts - WordPress
  5. Get blog page URL - WordPress