Bird
0
0

You want to prompt the user for their first and last name separately, then print them together. Which script correctly does this?

hard🚀 Application Q8 of 15
Bash Scripting - User Input
You want to prompt the user for their first and last name separately, then print them together. Which script correctly does this?
Aread -p "First name: last" read -p "Last name: first" echo "Full name: $first $last"
Bread -p "First name: " first read -p "Last name: " last echo "Full name: $first $last"
Cread first last -p "Enter names: " echo "Full name: $first $last"
Dread -p "Enter full name: " fullname echo "Full name: $fullname"
Step-by-Step Solution
Solution:
  1. Step 1: Understand separate prompts

    We need two separate prompts for first and last names.
  2. Step 2: Check each option

    read -p "First name: " first read -p "Last name: " last echo "Full name: $first $last" correctly prompts separately and stores in variables.
  3. Final Answer:

    Separate prompts with variables first and last, then echo combined -> Option B
  4. Quick Check:

    Separate prompts and variables = A [OK]
Quick Trick: Use separate read -p commands for multiple inputs [OK]
Common Mistakes:
MISTAKES
  • Putting variable names inside prompt text
  • Using wrong order of options
  • Trying to read multiple variables with -p incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes