Multiple flags

Fortunately for us, we do not have to be content with just a single flag: we can define many (right up until we run out of alphabet!).

We'll create a new script that will print a message to the reader. If no flags are specified, we'll print a default message. If we encounter either flag -b or flag -g, we'll print a different message, depending on the flag. We'll also include instructions for the -h flag, which will print a help message when encountered.

A script with these requirements could look something like this:

reader@ubuntu:~/scripts/chapter_15$ vim hey.sh reader@ubuntu:~/scripts/chapter_15$ cat hey.sh #!/bin/bash###################################### Author: Sebastiaan Tammer# Version: v1.0.0# Date: 2018-12-14# Description: ...

Get Learn Linux Shell Scripting - Fundamentals of Bash 4.4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.