Unknown
Unknown

Reputation: 676

Date command in Bash

How do I call the date +%a command in an if statement in bash? I've searched around google but can't find anything. I'm trying to create a script so that if date +%a presents Mon I echo Backup your files!

So far I've tried this:

if [date +%a==Mon]
then
echo back
fi

Among other variations.

What am i missing?

I apologize in advance if this a dumb question, I'm new to Bash.

Upvotes: 0

Views: 960

Answers (1)

choroba
choroba

Reputation: 242198

Use command substitution:

if [[ $(date +%a) == Mon ]] ; then
   echo Backup time
fi

Upvotes: 1

Related Questions