a),
#使用read命令读取一行数据
while read myline
do
echo "LINE:"$myline
done < datafile.txt
b),
#使用read命令读取一行数据
cat datafile.txt | while read myline
do
echo "LINE:"$myline
Done
c),
#读取一行数据
cat datafile.txt | while myline=$(line)
do
echo "LINE:"$myline
Done
d),
#读取一行数据
while myline=$(line)
do
echo "LINE:"$myline
done < datafile.txt
e),
#使用read命令读取变量数据
cat datafile.txt | while read paraa parab parac
do
echo "PARAA:"$paraa
echo "PARAB:"$parab
echo "PARAC:"$parac
Done
f),
#使用read命令读取变量数据
while read paraa parab parac
do
echo "PARAA:"$paraa
echo "PARAB:"$parab
echo "PARAC:"$parac
#使用read命令读取一行数据
while read myline
do
echo "LINE:"$myline
done < datafile.txt
b),
#使用read命令读取一行数据
cat datafile.txt | while read myline
do
echo "LINE:"$myline
Done
c),
#读取一行数据
cat datafile.txt | while myline=$(line)
do
echo "LINE:"$myline
Done
d),
#读取一行数据
while myline=$(line)
do
echo "LINE:"$myline
done < datafile.txt
e),
#使用read命令读取变量数据
cat datafile.txt | while read paraa parab parac
do
echo "PARAA:"$paraa
echo "PARAB:"$parab
echo "PARAC:"$parac
Done
f),
#使用read命令读取变量数据
while read paraa parab parac
do
echo "PARAA:"$paraa
echo "PARAB:"$parab
echo "PARAC:"$parac
done < datafile.txt
例子:
#!/bin/sh
ip=192.168.253.111
while read line <&3 ; do
echo " attempt with ($line)"
# Try to connect and exit when done if it worked.
$line && exit 0
done 3<<EOF
/usr/bin/rlogin -l snap-admin $ip
/usr/bin/ssh dev@$ip
/usr/bin/ssh snap-admin@$ip
/usr/bin/ssh root@$ip
EOF