
redirect | 677
Bash and Korn
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
-n count
Read at most count bytes. Not ksh88.
-p prompt
Bash: print prompt before reading input.
-p Korn shell: read from the output of a |& coprocess.
-r Raw mode; ignore \ as a line-continuation character.
-s Bash: read silently; characters are not echoed.
-s Korn shell: save input as a command in the history file.
-t timeout
When reading from a terminal or pipe, if no data is entered
after timeout seconds, return 1. This prevents an application
from hanging forever, waiting for user input. Not ksh88.
-u[n]
Read input from file descriptor n (default is 0).
Examples
Read three variables:
$ read first last address
Sarah Caldwell 123 Main Street
$ echo "$last, $first\n$address"
Caldwell, Sarah
123 Main Street
Prompt yourself to enter two temperatures, Korn shell version:
$ read n1?"High low: " n2
High low: 65 33
readonly
readonly [-afp] [variable[=value] ...]
Prevent the specified shell variables from being assigned new
values. An initial value may be supplied using the assignment
syntax, but that value may not be changed subsequently.
Options
ksh88 does not accept options for this command.
-a Each variable must refer to an array. Bash only.
-f Each variable must refer to an function. Bash only.
-p Print readonly before printing the names and values of read-
only variables.