Alternate a BASH variable by Date

pablo808

What method can one use to alternate a variable which is dependable by time?

For example, this week var = Office, then next week var = Oncall?

The resulting script will be using crontab to output the contents of var depending on which week it was.

Thanks.

that other guy

You can use date +%W to check what week number of the year it is (starting Monday).

You can alternate between the two with e.g.

if (( $(date +%W) % 2 ))
then
  var=Office
else
  var=Oncall
fi

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Saving variable with date in bash

How to restructure a date variable in bash

How to assign a formatted date to a bash script variable

Set a variable on bash with the current date including tab

How convert Date variable format in bash

bash script - need date command variable

include date format into another variable in bash

Powershell equivalent of Bash "Alternate Value"

Using the "alternate screen" in a bash script

Display alternate UserForm dependent on variable

Ext.data.field.Date - alternate format

DateTime object and displaying date/time in alternate timezone

How to get the date from the alternate datepicker field?

How to work with date command in a bash script through variable

Getting date of X days ago in bash script, using argument variable

Save Creation Date of File into Variable - BASH Script - UNIX

Current time/date as a variable in BASH and stopping a program with a script

Why is my bash script not recognizing the variable in the date command?

I want to Extract the date from this string in Bash and save it to a variable

Best way to alternate a variable value in loop? (Perl)

How to use BehaviorRelay as an alternate to Variable in RxSwift?

PHP & HTML Alternate syntax for foreach: Undefined variable

Fill ggplot barchart variable's category to alternate colour by variable

Word Macro object variable or with block variable not set on alternate run

Date command as a variable in a bash script. Needs to be invoked each time instead of during variable declaration

date Date variable

jQuery UI Datepicker populate and format alternate field as MySQL date

In JQuery Date picker need to disable alternate weeks in a month

How to alternate between file input and terminal input in bash