blog-web/source/_posts/linux/2.3、shell(4)-使用技巧.md
结发受长生 10e4564c71 时间调整
2018-05-20 19:39:08 +08:00

479 B

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

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

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

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

逐行读取文件

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