#!/bin/bash # while 循环 i=0; while [ $i -lt 10 ];do ((i++)); done echo $i;
# read -p "Please input number:" Please input number:10
root@Ubuntu:/home/shell# read -p "Please input number:" input Please input number:100 root@Ubuntu:/home/shell# echo $input 100
while 读取文件信息,这件事for就不好处理了。
#!/bin/bash # while read line 读取文件信息 read -p "请输入文件地址:" input if [ ! -f $input ];then echo "文件不存在" exit fi # 读取文件内容 while read line do echo $line done < $input