Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} instead of backticks.
Using square brackets [] which are for tests, not command substitution.
✗ Incorrect
Backticks (`) are used to run a command and capture its output in a variable.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The modern way to do command substitution is using $(command).
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using braces or brackets which cause syntax errors.
Missing closing backtick or parenthesis.
✗ Incorrect
Use $(command) to correctly capture the output of ls -1 into the variable.
4fill in blank
hardComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using backticks without closing them.
Using braces or missing closing parenthesis.
✗ Incorrect
Use $(pwd) to run pwd and print the current directory.
5fill in blank
hardComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing $() and backticks incorrectly.
Forgetting to close the command substitution.
✗ Incorrect
Use $(wc -l filename.txt) to count lines and assign output to variable.