How to test the current days to compare a given day?

Hi,

I tested this :

#!/bin/bash
set +x

CurrentDay=$(date +'%a') (Fri) on my server
Fri=$(date -d "Friday" | awk '{print $1}')
Sat=$(date -d "Saturday" | awk '{print $1}')

if [[ $CurrentDay == "$Sat" ]] ; then echo "ok" ; else echo "ok" ; fi

But the output tell me always "ok" why?! Thanks in advance :b:

Because your else says Ok too...

Regards...

OMG, I go out ! I hang me :eek::eek::eek:

Thanks :b:

Hello Arnaudh78,

Off course if you have a coin whose both sides are either heads or tails then it will be each time heads or tails(depending which one you have both the sides). Your code tells in if statement if condition is TRUE then print ok and when it is NOT true means go to else then also print ok , so that only it is printing each time the same. Try changing it to NOT ok etc. Let us know if you have any queries on same.

Thanks,
R. Singh

I made a big stupid mistake of inattention sorry...

Hello Arnaudh78,

You need not to be sorry, we all are human beings, we learn and go forward. Need not to worry, just enjoy learning :b:

Thanks,
R. Singh