Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to prompt the user for their name and store it in the variable.
Bash Scripting
read [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to include the variable name after the prompt.
Using '-n' instead of '-p' for prompting.
✗ Incorrect
The '-p' option in 'read' allows you to display a prompt message. The correct syntax is 'read -p 'prompt' variable'.
2fill in blank
mediumComplete the code to prompt the user for their age and store it in the variable 'age'.
Bash Scripting
read [1] age Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-n' which limits the number of characters read instead of prompting.
Using '-s' which hides input (used for passwords).
✗ Incorrect
The '-p' option displays the prompt message before reading input into the variable.
3fill in blank
hardFix the error in the code to correctly prompt for a password without showing input.
Bash Scripting
read [1] password Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only '-p' which shows input.
Using '-n' which limits input length instead of hiding input.
✗ Incorrect
To prompt without showing input, use '-s' to hide input and '-p' to show the prompt message.
4fill in blank
hardFill both blanks to prompt the user for their favorite color and store it in 'color'.
Bash Scripting
read [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-s' which hides input when not needed.
Using wrong variable names.
✗ Incorrect
Use '-p' with the prompt message and specify the variable name 'color' to store the input.
5fill in blank
hardFill all three blanks to prompt for username and password, hiding password input.
Bash Scripting
read [1] username read [2] [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not hiding password input.
Forgetting to specify variable names.
✗ Incorrect
First prompt uses '-p' for username. Second prompt uses '-s -p' to hide password input and show prompt, storing input in 'password'.