From the course: Linux: Bash Shell and Scripts

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Positional parameters and operators with braces

Positional parameters and operators with braces - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

Positional parameters and operators with braces

- [Instructor] Let's look at parameters to your shell script as well as some fancy stuff with the curly braces. So, as we've seen parameters to the shell script are numbered. We call those positional parameters. You can have a million of them or more. You can have a lots. But if you have one that's more than one digit for which one it is then you need to put the number in braces. You can't say dollar of one zero. You need to say dollar, open curly brace, one, zero, close curly brace. And dollar, zero for a shell program is the path to the program itself. That can be handy in an error message. Instead of hard coding the name of the shell program you just refer to it as dollar zero. So, if the shell program is renamed your message still makes sense. Bash has a command called shift which moves the positional arguments. If you say shift then what was in dollar two goes into dollar one. What was in dollar three goes into dollar two and so forth. This way you can loop just looking at dollar…

Contents