Introduction
The read command lets your script wait for the user to type something. It saves what the user types into a variable so your script can use it later.
read [options] variable_name
read name
read -p "Enter your age: " ageread -s password
read var1 var2
#!/bin/bash echo "What is your favorite color?" read color echo "You chose: $color"
read command do in a bash script?readread command pauses the script and waits for the user to type something.username?read variable_name without any special characters.read username, which correctly stores input in username. Others misuse flags or symbols.echo "Enter your age:"
read age
echo "You are $age years old."
age, then prints a message using that input.read -p "Enter your city: " city
echo "City is $city"
-p option allows showing a prompt before reading input, which is valid in bash.city is correctly placed after the prompt, and quotes around prompt text are correct.first and last, from one line of user input separated by space. Which command correctly does this?read command can take multiple variable names to split input by spaces.read first last to read two words into two variables. read -p first last misuses -p. read first; read last reads twice separately. read -a first last uses -a incorrectly here.Pass the test and this pattern moves unknown