bash编程控制语句

if

比较两个变量的大小并输出不同的值
i f [ $a -eq $b ]; then echo “equal”; elif [ $a -lt $b ];then echo “small”; elif [ $a -gt $b ];then echo “big”;fi

for

循环读取文件内容并输出
for i in $(cat dir.txt);do echo $i;done

while

循环读取文件内容并输出
while read line;do echo $line;done<dir.txt

posted @ 2021-11-05 22:49  皮子成  阅读(36)  评论(0)    收藏  举报