Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash: Loop over dates
#!/bin/bash
now=`date +"%Y-%m-%d" -d "05/06/2012"`
end=`date +"%Y-%m-%d" -d "05/23/2012"`
while [ "$now" != "$end" ] ;
do
now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
echo $now
done
@chikatambun

This comment has been minimized.

Copy link

chikatambun commented Dec 6, 2015

start=$(date '+%T')
end=$(echo $(date --date '+1 min') | awk '{print $4}')
while [[ $end > $(date +%T) ]];
do
brute.py ftp_login host=202.148.32.101 user=another_ct password=slowdown
done

@j450h1

This comment has been minimized.

Copy link

j450h1 commented Oct 1, 2016

I'm trying to run this on Mac and I get:

date: illegal time format

Any tips?

@tanzyy

This comment has been minimized.

Copy link

tanzyy commented Mar 28, 2017

on Mac, use -v option.

$(date -v -1d +"%Y-%m-%d")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.