Final answer:
Command substitution in shell script can be done using '‘command’' or ‘$(command)’. The other options reference variables but do not perform command substitution. option b is the correct answer.
Step-by-step explanation:
The question is about command substitution within a shell script. Command substitution is a feature of the shell that allows the output of a command to replace the command itself in a line of code. In shell scripting, you can perform command substitution in two primary ways:
- ‘command’
- $(command)
Both these methods will execute the command and substitute its output in place. Option b ${command} is used to reference a variable and c ${!command} is used for indirect variable references, not for command substitution.
The correct options for performing command substitution within a shell script are a. 'command' and d. $(command). Command substitution allows the output of a command to be used as part of another command or assignment.
For example, if you have a file named 'file.txt' and want to count the number of lines in it, you can use lines=$(wc -l < file.txt). The $(command) format captures the output of the 'wc -l' command and assigns it to the 'lines' variable.