oinume journal

Scratchpad of what I learned

Loop over dates with bash in Linux

Here is an example of looping over dates from 2017-10-22 to 2017-12-31.

#!/bin/bash

START=2017-10-22
END=2017-12-31

CURRENT=$START
while true; do
    echo $CURRENT
    if [ "$CURRENT" = "$END" ]; then
        break
    fi
    CURRENT=`date -d "$CURRENT 1day" +%Y-%m-%d`
done

NOTE