O'Reilly logo

Learning Shell Scripting with Zsh by Gastón Festari

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

Expansion

The shell allows you to perform different types of manipulations right before executing a line. In the following section we'll learn how to take advantage of each of the different forms of expansion and substitution available in zsh.

Parameter expansion

Parameter expansion allows you to replace known variables in between the assignments of the command line. Simply put, parameter substitution is the mechanism by which the shell can change the following:

% foo=Hello

It will be changed to the following:

% echo "${foo}, world!"
> Hello, world!

Notice how the variable foo we declared in the previous line is replaced inside the arguments of echo with its actual value. You should be paying special attention to that peculiar ${} construction. ...

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