How to check if today is a weekend in bash?

前端 未结 7 1655
悲哀的现实
悲哀的现实 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:03

    printf also has date

    printf -v day '%(%a)T'
    case $day in 
        Sat|Sun) echo "Hooray!";;
    esac
    

    https://ideone.com/wU7C0c - demo

提交回复
热议问题