Read one line from stdin with a prompt.

Section: Reading Input

Prompt user for input

bash
bash
read -r -p 'Enter name: ' name
Explanation

-r prevents backslash escaping during input.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Reading Input
Read secret silently
Read secret input without echoing characters.
OpenIn sheetbashsame section
Read delimited fields
Parse delimited input into multiple variables.
OpenIn sheetbashsame section
Load file into array
Read all lines of a file into an array.
OpenIn sheetbashsame section
Create indexed array
Create an indexed array.
Create associative array
Declare an associative array.
Lowercase string
Convert a string to lowercase.