O'Reilly logo

A Practical Guide to Red Hat® Linux® 8 by Mark G. Sobell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Shell Basics

This section covers variables and assignment statements and how to write a simple shell script and make it executable.

Assignment Statements

The Bourne Again, TC, and Z Shells allow you to create and use variables. The rules for naming and referring to variables are similar in all three shells (page 566). You assign values to variables in the Bourne Again and Z Shells with the following syntax:

VARIABLE=value

There can be no whitespace on either side of the equal (=) sign. If you want to include SPACEs in the value of the variable, put quotation marks around the value or quote the SPACEs.

In all three shells you reference the value of a variable by preceding the variable name with a dollar sign and enclosing it in braces, as in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required