Can anyone please help me to get the previous week number ?
I tried following before askign this here.
This one works but not able to couple it with year number.
echo `date +%W `-1 | bc``
2
Here are the failures I am getting while coupling year and previous week number
echo `date +%Y`wk`date +%W `-1 | bc``
(standard_in) 1: parse error
echo "`date +%Y`wk`date +%W `-1 | bc``"
2016wk03-1 | bc
CUrrentYEARwkPREVIOUSWEEK
like
2016wk02
Note: I am trying to get this done using oneliner , trying to avoide use of variable here.
You can use -d 'last week'
option and avoid bc
etc:
date -d 'last week' '+%Ywk%W'
2016wk02
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With