2001-07-10 14:25:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Same as previous example, but with "until" loop.
|
|
|
|
|
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
2001-09-04 13:27:31 +00:00
|
|
|
Filename=names.data # Default, if no filename specified.
|
2001-07-10 14:25:50 +00:00
|
|
|
else
|
|
|
|
Filename=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# while [ "$name" != Smith ]
|
|
|
|
until [ "$name" = Smith ] # Change != to =.
|
|
|
|
do
|
2001-09-04 13:27:31 +00:00
|
|
|
read name # Reads from $Filename, rather than stdin.
|
2001-07-10 14:25:50 +00:00
|
|
|
echo $name
|
2014-07-05 13:38:40 +00:00
|
|
|
done <"$Filename" # Redirects stdin to file $Filename.
|
2001-10-15 14:21:41 +00:00
|
|
|
# ^^^^^^^^^^^^
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
# Same results as with "while" loop in previous example.
|
|
|
|
|
|
|
|
exit 0
|