Read (Unix)

read is a command found on Unix and Unix-like operating systems such as Linux.

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

read is a command found on Unix and Unix-like operating systems such as Linux. It reads a line of input from standard input or a file passed as an argument to its -u flag, and assigns it to one or more variables. Each variable is assigned a successive token (word) from the input where tokens are normally split either by spaces or tabs.

If there are more variables than tokens then the remaining variables are unchanged. If there are more tokens than variable then the remaining tokens are assigned to the last variable listed in the command. If the -a flag is used all of the tokens are loaded as separate items into the 1st argument as an array.

It is built into shells such as Bash.

Configuration

The command supports several options via flags. It can be configured to issue a message using -p instead of needing to use the echo command.

It can also superficially hide text using the -s flag, limit the amount of characters with -n, store the result in an array with -a, and timeout after a certain amount of time with -t. The -e flag tells read to use the GNU readline library to handle the input. The -i arguments flag, which can only be used with -e, supplies a default input string which the user can then accept or modify.

Text derived from https://en.wikipedia.org/w/index.php?oldid=1378755601 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

3 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.