united states of america usa  linkedinfacebookgoogle
Bash: determine if the week is odd or even

bash

Here's a quick way to determine if the week is odd or even in bash. You can replace the "even" and "odd" with whatever functions you are looking to perform (eg. backup)

Copy and paste this into a file:

#!/bin/bash
WEEK=`date +"%V"`
if [ $(($WEEK%2)) -eq 0 ];
then
    echo "even";
else
    echo "odd";
fi

Tel: (786) 646-6461   |   Toll-Free: (877) 454-0758
18350 NW 2nd Ave, Suite 406E, Miami, FL, 33169, USA
Privacy Policy