Combining positional arguments and read

By combining both methods, of course! Before we start executing the actual functionality of the script, we need to verify whether  all necessary information has been supplied. If it has not, we can then prompt the user for the missing information.

We're going to look ahead slightly to Chapter 11, Conditional Testing and Scripting Loops, and explain the basic use of if-then logic. We'll combine this with the test command, which we can use to check if a variable contains a value or is empty. If that is the case, then we can prompt the user with read to supply the missing information.

At its heart, if-then logic is nothing more than saying if <something>, then do <something>. In our example, if

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.