From the course: Learning Bash Scripting
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Working with variables - Bash Tutorial
From the course: Learning Bash Scripting
Working with variables
- [Narrator] Variables allow us to store, modify, and use values by referring to them by name. When writing scripts, we'll use variables frequently. In Bash, variables are an expression of parameter expansion, which we saw a little bit earlier. In Bash, parameters, or in this case, variables are named with alpha numeric characters, and we assign a value to that name with an equal sign followed by whatever value we want it to store. It's important to remember that there should be no space on either side of the equal sign. Variable names are case sensitive. In many cases, we'll use lowercase names for our variables. Though you can use capitalized or all caps names too. Using lowercase variables helps us to distinguish our variables from environment and system variables, which are nearly always upper case. Here in the terminal, I'll write my greeting equals hello. If we put spaces around the equal sign, we'll get an error when we…
Contents
-
-
-
-
Understanding Bash script syntax5m 18s
-
(Locked)
Choosing a text editor for Bash scripting1m 33s
-
(Locked)
Displaying text with "echo"4m 26s
-
(Locked)
Working with variables5m 21s
-
(Locked)
Working with numbers8m 44s
-
(Locked)
Comparing values with test4m 59s
-
(Locked)
Comparing values with extended test3m 34s
-
(Locked)
Formatting and styling text output8m 13s
-
(Locked)
Formatting output with printf5m 6s
-
(Locked)
Working with arrays4m 25s
-
(Locked)
Challenge: Make a script that generates a system report1m 1s
-
(Locked)
Solution: Make a script that generates a system report1m 26s
-
-
-
-
-