From the course: Linux: Shells and Processes

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Command and variable substitution

Command and variable substitution - Linux Tutorial

From the course: Linux: Shells and Processes

Command and variable substitution

- [Instructor] Two of the most powerful features of the shell are command and variable substitution. Let's start with variable substitution. We can insert a variable into a text string and have it processed by the shell. The result is, the value of the variable being inserted in place of the variable. Let's see variable substitution in action. Type into a terminal echo "My shell is $SHELL" and hit Enter. This outputs the text "My shell is" followed by the value in the shell variable. In order to have reliable variable substitution, you need to use double quotes. This echo example is pretty basic. Now let's use a command to process the value of a variable. To set this up, let's create a couple of variables. Type in pdir="/tmp/files/today" and hit Enter. Now, let's create another one. fname="report" and hit Enter. Most system variables are uppercase, but variable names can be uppercase or lowercase. Now let's use these…

Contents