Variables
Like bash and tcsh, zsh allows you to create and use variables. The rules for naming and referring to variables are similar in all three shells (page 566). As in the Bourne Again Shell, you assign values to variables 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 zsh, as in bash and tcsh, you reference the value of a variable by preceding the variable name with a dollar sign and enclosing it in braces, as in ${VARIABLE}. The braces are optional unless the name of the variable is followed by a letter, digit, or underscore. Also, the Z Shell refers to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access