Bird
0
0

Which of these is the correct syntax to prompt the user and read their input into a variable named name?

easy📝 Syntax Q12 of 15
Bash Scripting - User Input
Which of these is the correct syntax to prompt the user and read their input into a variable named name?
Aread -p "Enter your name: " name
Binput "Enter your name: " > name
Cecho "Enter your name: " | read name
Dread name "Enter your name: "
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct read usage with prompt

    The -p option with read shows a prompt before waiting for input.
  2. Step 2: Check variable assignment

    The variable name comes after the prompt option, so read -p "Enter your name: " name is correct.
  3. Final Answer:

    read -p "Enter your name: " name -> Option A
  4. Quick Check:

    Prompt with -p = D [OK]
Quick Trick: Use read -p to prompt and read input [OK]
Common Mistakes:
MISTAKES
  • Using input instead of read
  • Placing prompt after variable name
  • Piping echo into read incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes