read

noun

say it: “REED” /ˈrid/

A shell command that waits for the user to type a line, then stores what they typed in a variable.

What does read do in bash?

read waits for someone to type a line and press Enter, then keeps the answer in a variable, so a script can ask questions. -p shows a question on the same line, -s hides the typing for a password, and -r keeps backslashes as typed.

read -r -p "Who is the card for? " name
echo "Happy birthday, $name!"

In a sentence

  • “The script uses read to ask who the card is for.”
  • “With read -s, the password Sam typed never showed on the screen.”

Level: Apprentice · More Unix terms at this level

Updated