Date calculation in linux

Posted on

Date calculation in linux – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, shell-scripting, , , .

In linux how to get the date of the first day of the week monday.

I know that date +”%u” gives the current day of the week from this how to get the date of the monday of that week

Solution :

The date command is very flexible about the input it will take from -d Try this


if [ $(date +%u) -eq "1" ]
   date -d "last monday"

You can do

date --date="Monday"

to get the date of this Monday. You can also do

date --date="next Monday" 

to get the date of the next Monday. You can also use “last Monday” to get the date of the previous Monday.

Refer to the Man pages for more details.

Leave a Reply

Your email address will not be published.