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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityFrom 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.
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