#!/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