Shell Script: Week Numbers in Unix / Linux

If you need to run scripts on specific weeks on a UNIX machine, then there is a easy way to determine this.

Based on this article’s date, we are currently on week 43 of 2013. To get the week number we just use the date command with the +%V format option. The week numbers will be in the range from 1 to 53.

# date 
Sat, Oct 26, 2013  4:07:20 PM
# date +%V
43

The week number is derived based on ISO 8601 standard.

Note that the date command supports another week number format – +%W. This prints week numbers from 0 to 53 and this might not be what you are looking for.

# date 
Sat, Oct 26, 2013  4:15:30 PM
# date +%V
42

The following code snippet can be used to run your stuff for a specific week in a shell script.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }