blog-web/source/_posts/linux/2.3、shell(4)-使用技巧.md
2018-05-07 20:22:19 +08:00

476 B

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

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

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

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

逐行读取文件

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