Skip to content

Instantly share code, notes, and snippets.

@alexras
Created February 26, 2020 20:37
Show Gist options
  • Save alexras/9854d4909be6b858c88d66bf3d69e4cb to your computer and use it in GitHub Desktop.
Save alexras/9854d4909be6b858c88d66bf3d69e4cb to your computer and use it in GitHub Desktop.
Loop through dates by month in bash
#!/bin/bash
start_date=2019-10-01
end_date=2019-10-31
while [ "$start_date" != 2017-10-01 ]
do
echo $start_date $end_date
start_date=$(gdate -I -d "$start_date - 1 month")
end_date=$(gdate -I -d "$start_date + 1 month - 1 day")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment