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. Get current store details - Magento 1.9
  2. Simple ways to improve page conversion on product page
  3. Encrypt Email Addresses - PHP
  4. The add_image_size() function - WordPress best practices
  5. Remove page title using filter - WordPress