blog-web/source/_posts/linux/2.3、shell(4)-使用技巧.md
2018-05-10 09:47:30 +08:00

479 B

title date tags categories
2.3、shell(4)-使用技巧 2018-5-6 00:52:25
linux
shell
linux

判断上一条命令执行是否成功

$?变量的值是上一条命令执行的返回值 通过判断这个变量的值 , 可以知道上一条命令是否执行成功

if [ $? -eq 0 ];then
  echo "执行成功"
else
  echo "执行失败"
fi

逐行读取文件

while read LINE
do
  echo $LINE 
done < test.txt