0
0
Bash Scriptingscripting~10 mins

Silent input with read -s (passwords) 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 password silently using read.

Bash Scripting
read -s [1] -p "Enter password: "
Drag options to blanks, or click blank then click option'
A-p
B-n
C-r
D-s
Attempts:
3 left
💡 Hint
Common Mistakes
Using -p instead of -s will show the input.
Using -r or -n does not hide input.
2fill in blank
medium

Complete 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'
Ainput
Bpassword
Cpass
Dsecret
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not matching the prompt.
Leaving the variable name blank.
3fill in blank
hard

Fix 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'
A-s
B-r
C-n
D-e
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add -s causes input to be visible.
Using options that do not hide input.
4fill in blank
hard

Fill 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'
A-s
B-p
Cpassword
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up options and variable names.
Not using -s for silent input.
5fill in blank
hard

Fill 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'
A-s
Bpassword
Dpass
Attempts:
3 left
💡 Hint
Common Mistakes
Not using -s in both read commands.
Using different variable names inconsistently.