Introduction to Unix |
|
![]() |
![]() |
5.11. readΒΆ
Linux for Programmers and Users, Sections 6.3.7
-
read
The
read
command is useful for reading data into a variable and as the boolean test of a Control Constructs. Like test,read
sets the Exit Code to indicate if a value was read. When the end-of-file (EOF) character is read, it sets the Exit Code to false, so it works well with a while loop when standard input is redirected to read from a file.
- SYNOPSIS
- read variable
Examples:
echo -n "Please enter your name: "
read name
echo "Your name is $name"
while read line
do
echo $line
done