How to check if today is a weekend in bash?

前端 未结 7 1752
悲哀的现实
悲哀的现实 2020-12-25 11:41

How to check if today is a weekend using bash or even perl?

I want to prevent certain programs to run on a weekend.

7条回答
  •  盖世英雄少女心
    2020-12-25 12:13

    I like this way of running programs on weekdays:

    [[ $(date +%u) -lt 6 ]] && weekday-program
    

    It is a bit tricky construction, but compact and easy to add.

提交回复
热议问题