0
0
Bash Scriptingscripting~10 mins

read command 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 a user's name into the variable 'name'.

Bash Scripting
read [1]
Drag options to blanks, or click blank then click option'
Aname
Binput
Cuser
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not declared or intended.
Forgetting to specify a variable after read.
2fill in blank
medium

Complete the code to prompt the user with 'Enter age:' before reading input into 'age'.

Bash Scripting
read -p "Enter age: " [1]
Drag options to blanks, or click blank then click option'
Aage
Buser_age
Cinput
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not match the prompt context.
Omitting the variable name after read.
3fill in blank
hard

Fix the error in the code to read two variables 'first' and 'last' from one input line.

Bash Scripting
read [1] [2]
Drag options to blanks, or click blank then click option'
Afirst last
Bfirst, last
Clast
Dfirst
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or semicolons between variable names.
Trying to read multiple variables as one combined variable.
4fill in blank
hard

Fill both blanks to read input into 'username' and 'password' variables with a prompt.

Bash Scripting
read -p "Enter [1] and [2]: " [1] [2]
Drag options to blanks, or click blank then click option'
Ausername
Bpassword
Cuser
Dpass
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between prompt text and variable names.
Using different names in prompt and variables.
5fill in blank
hard

Fill all three blanks to read three variables 'city', 'state', and 'zip' from one input line.

Bash Scripting
read [1] [2] [3]
Drag options to blanks, or click blank then click option'
Acity
Bstate
Czip
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single variable for multiple inputs.
Separating variable names with commas or other characters.