Skip to main content
p. 312

11.13 Reading User Input

The read command reads a line of text from the standard input and stores the text in a variable. For example, the following command stores the input in $var:

$ read var

This built-in shell command can be useful in conjunction with other shell features not mentioned in this book. With read, you can create simple interactions, such as prompting a user to enter input instead of requiring them to list everything on the command line, and build “Are you sure?” confirmations preceding dangerous operations.