May 4, 2017

[HDGEM] How to loop through date in bash

# slightly malformed input data  input_start=2017-1-1  input_end=2017-2-23    # After this, startdate and enddate will be valid ISO 8601 dates,  # or the script will have aborted when it encountered unparseable data  # such as input_end=abcd  startdate=$(date -I -d "$input_start") || exit -1  enddate=$(date -I -d "$input_end")     || exit -1    d="$startdate"  while [ "$d" != "$enddate" ]; do     echo $d    d=$(date -I -d "$d + 1 day")  done

for i in 2017-01-{01..31} 
for i in 2017-02-{01..28} 2017-{04,06,09,11}-{01..30}
   -I[TIMESPEC], --iso-8601[=TIMESPEC]                output date/time in ISO 8601 format.  TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time                to the indicated precision.    

Posted By Blogger to HDGEM at 5/04/2017 08:57:00 AM
Post a Comment

Featured Post

DMARC is a type of email authentication protocol that leverages the widely used SPF and DKIM protocols to improve a sender’s understanding of how their email in circulation is processed.

Email claiming to be from their domain is analyzed by receiving organizations and a digest of acceptance/failures is sent back to the sende...