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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Escape characters and quotes5m 44s
-
(Locked)
Brace expansion6m 12s
-
(Locked)
Command and variable substitution7m 14s
-
(Locked)
Command input and output1m 55s
-
(Locked)
Connecting programs with pipes4m 19s
-
(Locked)
File redirects and tees6m 8s
-
(Locked)
Combining pipes, redirects, and tees6m 41s
-
(Locked)
Command lists and subshells7m 53s
-
(Locked)
-
-
-