0
0
Bash Scriptingscripting~10 mins

String variables 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 assign the text "Hello" to a variable named greeting.

Bash Scripting
greeting=[1]
Drag options to blanks, or click blank then click option'
Agreeting
B"Hello"
CHello
D'Hello'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the string without quotes causes errors or unexpected behavior.
Using single quotes when double quotes are expected for variable expansion.
2fill in blank
medium

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
Printing the variable name as a string instead of its value.
Forgetting the $ sign before the variable.
3fill in blank
hard

Fix the error in the code to correctly assign the string "World" to the variable word.

Bash Scripting
word=[1]
Drag options to blanks, or click blank then click option'
A"World"
BWorld
C'World
DWorld"
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes or mismatched quotes cause syntax errors.
Using only one quote at start or end.
4fill in blank
hard

Fill both blanks to assign "Hello" to greeting and then print it.

Bash Scripting
greeting=[1]
echo [2]
Drag options to blanks, or click blank then click option'
A"Hello"
Bgreeting
C$greeting
DHello
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the variable name without $.
Assigning string without quotes.
5fill in blank
hard

Fill all four blanks to assign "User" to user, assign "Name" to name, then print both variables separated by a space.

Bash Scripting
user=[1]
name=[2]
echo [3] [4]
Drag options to blanks, or click blank then click option'
A"User"
B"Name"
C$user
D$name
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes in assignments.
Printing variable names without $.
Not separating variables with space in echo.