ACE-P-ALE1-04 practice question 9 of 35
In shell scripting, what are backticks, or backwards single quote marks, used for?
Full set: 100 questionsIn shell scripting, backticks ( ) are used for command substitution. This is a mechanism where the shell executes the command enclosed within the backticks and replaces the backticked expression with the standard output of that command. For example, if you execute currentdir=pwd, the shell first runs the pwd command, captures its output (e.g., /home/user), and then assigns this string to the currentdir variable. The $(...)` syntax is a more modern and generally preferred alternative that offers better nesting and readability.
A. Shell escapes are performed using the backslash character (\) to remove the special meaning from a single character.
B. Variable dereferencing is the process of accessing a variable's value, which is done using a dollar sign ($), as in $VAR.
D. Output formatting is controlled by specific commands like printf or options to commands like echo, not by backticks. ---
1. GNU Bash Reference Manual, Section 3.5.4 Command Substitution: "Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command... When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by ‘$’, ‘’, or ‘\’."
2. MIT, "The Missing Semester of Your CS Education", Lecture 1: The Shell: The course materials explain shell features, including command substitution. The notes state, "To use the output of a command as an argument to another command... you can use $(CMD)... An older syntax CMD is also supported." This confirms the use of backticks for this purpose.
3. Arista EOS 4.28.1F System Configuration Guide, Section: CLI Scripting: This guide details scripting on Arista devices. While it may not explicitly define backticks, the examples provided rely on standard Bash shell behavior, where command substitution is a fundamental feature for capturing command output within scripts running on the EOS Linux environment. For instance, capturing the output of a show` command into a variable uses this mechanism.
Keep practicing
Take the free ACE-P-ALE1-04 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other ACE-P-ALE1-04 practice questions
- Question 1When using the sudo command to run something as root, which password is required?
- Question 2Which utility can be used to remove sections or columns of each line of input?
- Question 3The ps –ef command is from which UNIX variant?
- Question 4In file globbing, which symbol matches any single character?
- Question 5If the system is swapping, what can be done to alleviate the problem?
- Question 6When scripting in bash, it is recommended to always use which symbols around your variabl…
