Bash Scripting - User InputYou 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"Check Answer
Step-by-Step SolutionSolution:Step 1: Understand separate promptsWe need two separate prompts for first and last names.Step 2: Check each optionread -p "First name: " first read -p "Last name: " last echo "Full name: $first $last" correctly prompts separately and stores in variables.Final Answer:Separate prompts with variables first and last, then echo combined -> Option BQuick Check:Separate prompts and variables = A [OK]Quick Trick: Use separate read -p commands for multiple inputs [OK]Common Mistakes:MISTAKESPutting variable names inside prompt textUsing wrong order of optionsTrying to read multiple variables with -p incorrectly
Master "User Input" in Bash Scripting9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Bash Scripting Quizzes Bash Scripting Basics - Creating a script file (.sh) - Quiz 2easy Bash Scripting Basics - Bash vs other shells (Zsh, Fish, sh) - Quiz 5medium Conditionals - Why conditionals branch script logic - Quiz 3easy Conditionals - if-elif-else - Quiz 12easy Loops - break and continue - Quiz 9hard Quoting and Expansion - Brace expansion ({1..10}) - Quiz 2easy Quoting and Expansion - Why quoting rules prevent errors - Quiz 7medium Quoting and Expansion - Tilde expansion (~) - Quiz 9hard Variables - String variables - Quiz 12easy Variables - Why variables store and reuse data - Quiz 6medium