Week number in Linux/Unix Shell Script
In Linux/Unix Shell scripts you can use the
date command to format dates.
This works on all disributions like Ubuntu, Mint, Suse, Debian etc. and also on the MacOS X command line.
Example: Command line
Get the current week number and print it on the interactive shell.
$ date +%v
Example: In a script
Assign the current week number to a variable and print it.
weeknumber=`date +%V` echo "Week number:$weeknumber"
Example: Week number of fixed date
To get the calendar week number for a specific date, use the following command:
date --date="1984-12-18" +"%V"
comments powered by Disqus