0
0
Bash Scriptingscripting~10 mins

Backticks and $() for command substitution in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to store the current date in the variable.

Bash Scripting
current_date=[1]date[2]
Drag options to blanks, or click blank then click option'
A[
B$(
C{
D`
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} instead of backticks.
Using square brackets [] which are for tests, not command substitution.
2fill in blank
medium

Complete the code to store the current user name using modern command substitution.

Bash Scripting
user_name=[1]whoami
Drag options to blanks, or click blank then click option'
A$(
B`
C)
D[
Attempts:
3 left
💡 Hint
Common Mistakes
Using backticks instead of $() which is the newer preferred style.
Using braces or brackets which are not for command substitution.
3fill in blank
hard

Fix the error in the code to correctly assign the list of files to a variable.

Bash Scripting
files=[1]ls -1
Drag options to blanks, or click blank then click option'
A$(
B`
C)
D[
Attempts:
3 left
💡 Hint
Common Mistakes
Using braces or brackets which cause syntax errors.
Missing closing backtick or parenthesis.
4fill in blank
hard

Complete the code to print the current directory using command substitution.

Bash Scripting
echo [1]pwd
Drag options to blanks, or click blank then click option'
A$(
B`
C)
D}
Attempts:
3 left
💡 Hint
Common Mistakes
Using backticks without closing them.
Using braces or missing closing parenthesis.
5fill in blank
hard

Complete the code to assign the number of lines in a file to a variable.

Bash Scripting
line_count=[1]wc -l filename.txt
Drag options to blanks, or click blank then click option'
A$(
B-l
C)
D`
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing $() and backticks incorrectly.
Forgetting to close the command substitution.