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?
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?
This question was answered in https://stackoverflow.com/questions/4351282/how-to-generate-a-sequence-of-dates-given-starting-and-ending-dates-using-awk-of . I like the @camh answwer.
You can create a shell script with this content,
#!/bin/bash
#./createdir 2010-02-02 2010-02-05
startdate=$1
enddate=$2
for d in $(seq $(date +%s -d $startdate) +86400 $(date +%s -d $enddate)); do
mkdir $(date +%Y%m%d -d @$d)
done
@1.29396e+09' date: invalid date
@1.29387e+09' Why does that happens?