Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi i need to create a series of folder with a range of date for exmaple

createdir 2010-02-02 2010-02-05

will create :

20100202/ 20100203/ 20100204/ 20100205/

What the best way to do this with a Shell Script or with a C POSIX program?

share|improve this question
Stackoverflow maybe? – Joseph Kern Mar 30 '11 at 23:26

This question was answered in . I like the @camh answwer.

You can create a shell script with this content,

#./createdir 2010-02-02 2010-02-05


for d in $(seq $(date +%s -d $startdate) +86400 $(date +%s -d $enddate)); do
  mkdir $(date +%Y%m%d -d @$d)
share|improve this answer
./ 2011-01-01 2011-01-02 date: invalid date @1.29396e+09' date: invalid date @1.29387e+09' Why does that happens? – Necronet Mar 31 '11 at 14:13
This code works in Ubuntu. Sounds like date command don´t understend the date format, YYYY-MM-DD. Try to call date with different date formats, for example, cturiel@menta:~/tmp$ date +%s -d 2010-02-02 1265065200 cturiel@menta:~/tmp$ date +%s -d 20100202 1265065200 cturiel@menta:~/tmp$ date +%s -d 2010/02/02 1265065200 – cturiel Mar 31 '11 at 21:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.