Shell Script: Check If Weekday

There are two ways to perform a “is it a weekday” logic in shell scripts. One way is to use cron. The other is to get the day of week from the date command.

To run a shell script every weekday via cron, set the “day of week” field to “1-5” (0 is Sunday).

The above crontab entry will run the script every weekday at 8am.

The other method is to add some logic in the script to determine if the current day is a weekday.

On Bash 4.2 and above, you can use the builtin printf command to determine the day of the week.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }