In these shell tutorials, we've been interacting with a computer through the command line. In order to interact with it, we type commands in, those commands are executed, and we're shown the results. That interaction is happening within a shell called bash. A shell is a way to access and control a computer. Command line shells have a text interface for typing commands and seeing results, versus graphical shells which allow you to click on icons with a mouse. There are many unix shells, but Bash is one of the most popular. Bash is the default shell on most Linux and OSX computers.
Bash is essentially a program that lets us run other programs. To do this, Bash implements a command language. This language specifies how we can type and structure commands that will be executed. A command language is a special kind of programming language through which we can control applications and the system. Just like other programming languages, like Python, we can create scripts, set variables, and more. Because it is a language, bash is far more powerful than a graphical shell.
We can set variables by assigning to them. Variables consist entirely of uppercase characters, numbers, and underscores. You can assign any datatype to a variable. Here are some examples:
OS=linux
OPERATING_SYSTEM="linux"
Both of the above variables OS
andOPERATING_SYSTEM
will actually be assigned the same value. Quotes are optional when using strings in bash, unless there's a space in the string -- bash is sensitive to spaces, and strings with spaces won't work properly if they aren't surrounded with quotes.
This assignment won't work:
ANIMAL=Shark with a laser beam on its head
But this will:
ANIMAL="Shark with a laser beam on its head"
It's also important not to add in stray spaces. This won't work:
ANIMAL = "Shark with a laser beam on its
head"
Instructions
- Create a variable
FOOD
containing the valueShrimp gumbo