Shell Programming Blog Shell Programming Blog

Tuesday, 30 October 2012

Linux Bash Scripting: How to create directories for each day of the current month

abu sittik | 09:59 | |

Bash Linux Unix shell scripting

 In this post I have written a script that creates an empty directory for each day of the current month. I used cal command to get the date and month instead of using date command. The reason is that the date command does not work in Solaris. To make it portable, I have used cal command.

The below script does the following
  • It takes the total number of days of the current month 
  • It gets the current month name from the cal command
  • It gets the current year from the cal command
  • It creates an empty directory for each day of the current month
  • Before creating, this checks whether the directory already exists, if yes, the script exits by displaying a message.

You can change the "dir" to the directory in which you want the folders to be created.


Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.

1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.
3. Please do not spam, spam comments will be deleted immediately upon my review.

Mohamed Abubakar Sittik A


Shell Programming Copyright © 2012 Shell Programming theme is Designed by Abusittik, Shell Programming