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

相关文章:

  • 2021-06-09
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2021-11-24
猜你喜欢
  • 2021-12-03
  • 2021-11-25
  • 2022-01-28
  • 2022-01-17
相关资源
相似解决方案