Bird
0
0

What will this script print if the user types 'mypassword' when prompted?

medium📝 Command Output Q5 of 15
Bash Scripting - User Input
What will this script print if the user types 'mypassword' when prompted?
read -s -p "Password: " pass

echo "You entered: $pass"
APassword: mypassword
BYou entered:
CYou entered: mypassword
DError: variable not set
Step-by-Step Solution
Solution:
  1. Step 1: Analyze read -s behavior

    The input is hidden but stored in variable 'pass'.
  2. Step 2: Check echo output

    The echo command prints the value of 'pass', which is the typed password.
  3. Final Answer:

    You entered: mypassword -> Option C
  4. Quick Check:

    Hidden input stored and printed correctly [OK]
Quick Trick: Echo variable after read -s shows input even if hidden during typing [OK]
Common Mistakes:
MISTAKES
  • Thinking echo won't show hidden input
  • Confusing prompt text with output
  • Assuming variable is empty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes