builtin

Bash read builtin

Reads one record into variables. -r preserves backslashes; IFS affects field splitting. Status is nonzero on EOF or other failures.

Formal Syntax & Structure

bash syntaxbash
read [-r] [-a array] [-d delim] [-p prompt] [name ...]

Return Value

exit status

Reads one record into variables. -r preserves backslashes; IFS affects field splitting. Status is nonzero on EOF or other failures.

Working Example

Example Snippetbash
printf '%s\n' '  a\b  ' > input.txtIFS= read -r line < input.txtprintf '[%s]\n' "$line"
Bash Reference