O'Reilly logo

Linux Shell Scripting with Bash by Ken O. Burtch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required