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 variables - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Shell variables
- [Instructor] Let's talk about variables in Bash and a couple other real fundamental important things. In Bash syntax, you give a variable of value using the equal sign and it's going to be important that you have no spaces on either side of the equal sign. And if the value on the right has any spaces in it, you need to put that value in quotes. For example, we've got a tricky situation here. Myvar equals this is some chars. And then we want the quote itself to be inside the value. So we have to put a backslash in front of the quote so we have quotes around everything and then we've got a backlash inside the quote to include the quote itself. So you'll see backslash in front of characters is used sometimes to escape the special meaning. All you need to do is make up a variable name and give it a value and that creates it. There are two places where variables are remembered in Bash. There's kind of the ordinary place and there's the environment or the exported place. You can make a…
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
-
-
-
Exploring the Bash documentation2m 27s
-
(Locked)
Setting the script interpreter and permissions5m 49s
-
(Locked)
Date and time commands5m 36s
-
(Locked)
Shell variables4m 28s
-
(Locked)
Bash startup2m 52s
-
(Locked)
Sourcing and aliasing with Bash3m 31s
-
(Locked)
Displaying text with the echo command4m 12s
-
(Locked)
Challenge: Exported variables, sourcing, and echo2m 17s
-
(Locked)
Solution: Exported variables, sourcing, and echo4m 7s
-
-
-
-
-