Last active
March 28, 2017 22:04
-
-
Save tanzyy/c3c1161a6fb38025fa06f1203574377a to your computer and use it in GitHub Desktop.
Loop with date (MAC)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# On MAC date -d option does not work rather -v. | |
# Below code logic is as follows: | |
# Create folders with date(in format YYYY-MM-DD) with consecutive dates until it reaches to input difference | |
# Here variable datediff is 28 meaning from current date, it will generate dates until there is difference of 28. | |
now=$(date -v -1d +"%Y-%m-%d") | |
datediff=28 | |
for (( c=0; c<=$datediff; c++ )) | |
do | |
echo $c; | |
now=(`date -v -"$c"d +"%Y-%m-%d"`); | |
mkdir /tmp/"$now" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment