From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Shell parameter expansion - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Shell parameter expansion
- [Instructor] Let's look at another kind of more advanced, but valuable, can save you a lot of programming, mechanism in bash that works with variables and values. Now, maybe you don't want to use this because it's a little bit of a challenge to get the hang of it in the beginning perhaps, but if you ever see this in someone's shell script, you want to know kind of what's going on so you can get a grasp or maybe at least look up what's going on and have it make more sense. So what happens here is you can use an operator inside this dollar sign brace stuff. For example, the colon dash is used to check whether a variable is unset or null. And if it's not, then you get the value of the variable. But it it is unset or null, then you get the value on the right-hand side. So it's kind of like getting a default value for a variable. If you do the colon equal, then if the variable doesn't currently have a value, then it's assigned that value and it's also returned. So these are handy ways of…
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
-
-
-
-
-
Defining filters and using head, tail, and wc3m 18s
-
(Locked)
The use of sed for powerful scripting5m 55s
-
(Locked)
Using AWK5m 22s
-
(Locked)
Positional parameters and curly braces for variables3m 40s
-
(Locked)
Shell parameter expansion3m 47s
-
(Locked)
Challenge: Looping and special variable operators1m 12s
-
(Locked)
Solution: Looping and special variable operators2m 23s
-
(Locked)
Challenge: sed and AWK1m 33s
-
(Locked)
Solution: sed and AWK3m 17s
-
-
-