Skip to main content

BASH builtin for retrieving data from standard input.

# To store data that you type from the keyboard:
read <variable>

# To store each of the next lines you enter as values of an array:
read -a <array>

# To enable backspace and GNU readline hotkeys when entering input with read:
read -e <variable>

# To specify the number of maximum characters to be read:
read -n <character_count> <variable>

# To use a specific character as a delimiter instead of a new line:
read -d <new_delimiter> <variable>

# To do not let backslash (\) act as an escape character:
read -r <variable>

# To display a prompt before the input:
read -p <"Enter your input here: "> <variable>