Command and Arithmetic Substitution

Two additional forms of substitution are command and arithmetic substitution. Command substitution enables you to capture the output of a command, whereas arithmetic substitution enables you to perform basic integer math using the shell.

Command Substitution

Command substitution is the mechanism by which the shell performs a given set of commands and then substitutes their output in the place of the commands. Command substitution is performed when a command is given as

							`command`
						

Here command can be a simple command, a pipeline, or a list.

Make sure that you are using the backquote character , not the single ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.