Skip to content

Instantly share code, notes, and snippets.

@louisje
Last active January 2, 2018 03:23
Show Gist options
  • Save louisje/e981689e05a2e3ac7a2f to your computer and use it in GitHub Desktop.
Save louisje/e981689e05a2e3ac7a2f to your computer and use it in GitHub Desktop.
#!/bin/sh
# usage: ./date_of_year.sh [ {year} ]
year=$1
if test -z "$year"; then
year=`date +'%Y'`
fi
next_year=`echo "$year + 1" | bc`
now=`date +"%Y-%m-%d" -d "$year-01-01"`
end=`date +"%Y-%m-%d" -d "$next_year-01-01"`;
while [ "$now" != "$end" ]; do
week=`date +"%a" -d "$now"`
echo "$now,$week"
now=`date +"%Y-%m-%d" -d "$now + 1 day"`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment