read Input in Bash
From the Bash Scripting cheat sheet · Input & Output · verified Jul 2026
read Input
Prompt for and parse user input.
bash
# Quick Reference
read -r -p "Name: " name
read -rsp "Password: " pass # -s hides input
read -ra parts <<< "a b c" # split into an array💡 Always use read -r - without it, backslashes in input are silently eaten.
⚡ -p prints a prompt, -s hides typed input (passwords), -t sets a timeout.
📌 read -ra arr <<< "$str" splits a string into an array on whitespace.
🟢 read returns non-zero on EOF/timeout - chain with || for a fallback value.
inputread