Shell Scripting – Command Substitution
A shell is an interface that helps users to connect with the system. Using a shell is equivalent to indirectly communicating with the operating system. In Linux distributed systems, each time we use the terminal, we connect with a shell. The job of a shell is to analyze Unix commands or instructions given by the user. This process involves taking commands from the user and converting them into a form that the kernel can easily understand. In simple words, it acts as a medium between the user and the kernel of the operating system. The kernel is the most crucial part of a computer’s operating system.
In order to understand command substitution, let us first discuss substitution in shell scripts. Substitution is a functionality by following which we can instruct the shell to substitute the actual value of an expression.
In the below program we have firstly created variable num and assigned it with the value 20 and then substituted the value of the num as 100 in the echo command.
#!/bin/sh num=100 echo -e "num: $num"