Bird
0
0

Which command correctly reads three variables var1, var2, and var3 from a single line of input in bash?

easy📝 Syntax Q3 of 15
Bash Scripting - User Input
Which command correctly reads three variables var1, var2, and var3 from a single line of input in bash?
Aread var1 var2 var3
Bread -p var1 var2 var3
Cread -a var1 var2 var3
Dread var1,var2,var3
Step-by-Step Solution
Solution:
  1. Step 1: Understand the read command syntax

    The basic syntax to read multiple variables is read var1 var2 var3.
  2. Step 2: Analyze options

    read var1 var2 var3 uses the correct syntax. read -p var1 var2 var3 incorrectly uses -p which is for prompt message. read -a var1 var2 var3 uses -a which reads into an array, not separate variables. read var1,var2,var3 uses commas which is invalid.
  3. Final Answer:

    read var1 var2 var3 -> Option A
  4. Quick Check:

    Basic read syntax for multiple variables [OK]
Quick Trick: Use 'read var1 var2 var3' to read multiple variables [OK]
Common Mistakes:
MISTAKES
  • Using commas between variable names
  • Using read -p incorrectly
  • Confusing array read with multiple variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes