Each time the read builtin is executed it parses the next line of the input, but where in the man page is this mentioned? How would I know this beforehand?

EDIT I guess @dirkt answered this.

1 Answer 1


From man bash:

read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]

One line is read from the standard input, [...]

It's in the section labeled SHELL BUILTIN COMMANDS.

  • Yeah, I saw that, but does "read from stdin" mean that you are modifying stdin? Dec 7, 2016 at 21:26
  • @zagortenay333 stdin by default refers to input from keyboard, so if you're reading from stdin it just means reading what you type in. Modifying stdin would mean reading from file or from pipe, so whatever text comes in from file or from pipe will be treated as input. See this for example: paste.ubuntu.com/23595339 The command is cat | while read line ; do echo "You said" "$line" ; done . I am typing in something to cat, and cat forwards it via pipe to read. By the way, while read line; do . . . done is very common way for reading multiline input Dec 7, 2016 at 21:33
  • I know that.. What I don't understand is how the phrase "read one line from stdin" means that the next time I read it it will be the next line of the input. Dec 7, 2016 at 21:35
  • The input here has multiple lines. Dec 7, 2016 at 21:36
  • Reading is usually sequentially, and "consumes" what you've read from the source (or advances the file position, etc.)
    – dirkt
    Dec 7, 2016 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .