December 1999
Beginner
528 pages
11h 10m
English
Use read to take information from the keyboard or from a line of text from a file and assign it to a variable. If you specify only one variable then the read will assign all input to that variable until it sees an end-of-file marker or the shell sees a carriage return.
The general format is:
read variable1 variable2...
One variable has been specified, which holds all text until the return key has been hit:
$ read name
Hello I am superman
$ echo $name
Hello I am superman
Here, we assign two variables to hold a first and a second name. The shell will use the space bar as the separator for each variable.
$ read name surname
John Doe
$ echo $name $surname
John Doe
If you type in too many fields of text, the shell will assign all ...
Read now
Unlock full access