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

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…

Contents