0
0
Bash Scriptingscripting~10 mins

Accessing variables ($var and ${var}) 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 print the value of the variable name.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
A${name}
Bname
C$name
D&name
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the dollar sign before the variable name.
Using the variable name without any prefix.
2fill in blank
medium

Complete the code to print the value of the variable path using braces.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
A${path}
B$path
Cpath
D$[path]
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of braces.
Omitting the dollar sign.
3fill in blank
hard

Fix the error in the code to correctly print the variable file followed by the string .txt.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
A${file}.txt
B${filetxt}
C$filetxt
D$file.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Writing $file.txt which looks for variable file.txt.
Concatenating without braces causing wrong variable name.
4fill in blank
hard

Fill both blanks to correctly print the variable user and then the string _data.

Bash Scripting
echo [1][2]
Drag options to blanks, or click blank then click option'
A${user}
B$user
C_data
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using $user_data which looks for variable user_data.
Forgetting to use braces to separate variable and text.
5fill in blank
hard

Fill all three blanks to create a variable count with value 5, then print it with braces and add the string items.

Bash Scripting
[1]=5
echo [2][3]
Drag options to blanks, or click blank then click option'
Acount
B${count}
C items
D$count
Attempts:
3 left
💡 Hint
Common Mistakes
Using $count without braces when appending text.
Forgetting to assign the variable before printing.