Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to read a password silently using read.
Bash Scripting
read -s [1] -p "Enter password: "
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -p instead of -s will show the input.
Using -r or -n does not hide input.
✗ Incorrect
The -s option makes read silent, so the input is not shown on the screen.
2fill in blank
mediumComplete the code to store the silent input into the variable 'password'.
Bash Scripting
read -s -p "Enter password: " [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not matching the prompt.
Leaving the variable name blank.
✗ Incorrect
The variable name after read stores the input; here it should be 'password'.
3fill in blank
hardFix the error in the code to correctly read a silent password input.
Bash Scripting
read -s -p "Enter password: " [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add -s causes input to be visible.
Using options that do not hide input.
✗ Incorrect
Adding -s makes the input silent; without it, input is visible.
4fill in blank
hardFill both blanks to read a silent password and then print a confirmation message.
Bash Scripting
read [1] -s -p "Password: " [2] echo "Password received."
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up options and variable names.
Not using -s for silent input.
✗ Incorrect
Use -s to hide input and store it in variable 'password'.
5fill in blank
hardFill all three blanks to read a silent password, confirm input, and print a success message.
Bash Scripting
read [1] -s -p "Enter password: " [2] echo read [3] -s -p "Confirm password: " confirm echo if [[ $[2] == $confirm ]]; then echo "Passwords match." else echo "Passwords do not match." fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using -s in both read commands.
Using different variable names inconsistently.
✗ Incorrect
Use -s for silent input, store first input in 'password', second silent input with -s again.