I want to have the day of week in the variable DOW
.
So I use the following bash-script:
DOM=$(date +%d) DOW=($($DOM % 7) ) | sed 's/^0*//'
Unfortunately there I get this error: bash: 09: command not found
. The expected result is 2 ( 9 % 7 = 2) in the variable $DOW
.
How can I get this working? It works for the days 1-8 but because of the C-hex, there is no number over 8 available and the following message appears: bash: 09: value too great for base (error token is "09")
.
+”%A” – Get weekday in full format i.e. as Tuesday. +”%a” – Get weekday in abbreviated format i.e. as Tue. +”%u” – Get day of week starting with Monday (1), i.e. mtwtfss. +”%w” – Get day of week starting with Sunday (0), i.e. smtwtfs.
Very simple. Just use the date command itself with correct options. Show activity on this post.
Use %u
. Like this:
DOW=$(date +%u)
From the man page:
%u day of week (1..7); 1 is Monday
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