From the course: Linux: Bash Shell and Scripts
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Positional parameters and operators with braces - Linux Tutorial
From the course: Linux: Bash Shell and Scripts
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Defining filters and using head, tail, and wc5m 3s
-
(Locked)
Using sed and AWK for more powerful scripting13m 22s
-
(Locked)
Positional parameters and operators with braces10m 7s
-
(Locked)
Challenges: Looping, special variable operators, sed, and AWK1m 54s
-
(Locked)
Solutions: Looping, special variable operators, sed, and AWK2m 25s
-
(Locked)
-
-