0
0
Bash Scriptingscripting~10 mins

Reading into multiple 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 read two words into variables name and age.

Bash Scripting
read [1] age
Drag options to blanks, or click blank then click option'
A-p
Binput
Cname
D-r
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -p or -r instead of variable names.
Forgetting to specify variable names after read.
2fill in blank
medium

Complete the code to read three variables: first, middle, and last.

Bash Scripting
read first middle [1]
Drag options to blanks, or click blank then click option'
Alast
Bname
C-a
Dsurname
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -a instead of variable names.
Using variable names that don't match the input order.
3fill in blank
hard

Fix the error in the code to correctly read two variables.

Bash Scripting
read first [1]
Drag options to blanks, or click blank then click option'
Asecond
B1st
Ctwo
Dfirst
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names starting with numbers.
Using invalid variable names with spaces or special characters.
4fill in blank
hard

Fill both blanks to read two variables and print them.

Bash Scripting
read [1] [2]
echo "Name: $name, Age: $age"
Drag options to blanks, or click blank then click option'
Aname
Bage
Cuser
Dyears
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names in read that don't match those in echo.
Using invalid variable names.
5fill in blank
hard

Fill all three blanks to read three variables and print a greeting.

Bash Scripting
read [1] [2] [3]
echo "Hello, $first $middle $last!"
Drag options to blanks, or click blank then click option'
Afirst
Bmiddle
Clast
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that don't match the echo statement.
Using invalid variable names or options instead of variable names.