Chapter 9. Parameters and Subshells
To serve as a flexible tool, a script has to be qualified when it is called, given additional information about how and where to perform its task. Like commands, a script is qualified using parameters. Switches and arguments make a script reusable, which in turn reduces costs and time.
Positional Parameters
There are three methods available to extend Linux scripts using parameters. The first method uses positional parameters. A script can refer to the parameters on the command line by the position (or order) in which they appear. Because the other two methods rely on positional parameters, they are discussed first.
The Bash variable $0
is the pathname of the script. It is not necessarily the full pathname, but ...
Get Linux Shell Scripting with Bash 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.