Bird
0
0

How can you use the read command to prompt the user with a message before input, storing the input in variable answer?

hard🚀 Application Q9 of 15
Bash Scripting - User Input
How can you use the read command to prompt the user with a message before input, storing the input in variable answer?
Aread answer -prompt "Your answer: "
Bread -p "Your answer: " answer
Cread --message "Your answer: " answer
Decho "Your answer:"; read answer
Step-by-Step Solution
Solution:
  1. Step 1: Understand prompt option

    -p flag shows prompt before reading input.
  2. Step 2: Check syntax correctness

    read -p "Your answer: " answer correctly prompts and reads input.
  3. Final Answer:

    read -p "Your answer: " answer -> Option B
  4. Quick Check:

    Use -p to prompt inline with read [OK]
Quick Trick: Use read -p "prompt" variable to prompt user [OK]
Common Mistakes:
MISTAKES
  • Using non-existent flags like -prompt or --message
  • Separating echo and read instead of using -p
  • Placing prompt after variable name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes