Command Substitution

We have looked at the use of the single quote (') and the use of the double quote ("), but the back quote (`) is also a shell metacharacter and it is used to enable command substitution.

If the shell sees a pair of back quotes in a command line it will execute the entire command contained inside the back quotes first and then replace it with the output from that command. Then it will run the original command.

So if we wanted to edit a script called script1.sh that existed in a directory included in our path we could use the which command (we've already described this earlier) to locate the script and then type in the full path name:

 $ which script1.sh /usr/local/bin/script1.sh $ vi /usr/local/bin/script1.sh <output removed ...

Get Solaris™ Operating Environment Boot Camp 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.