【发布时间】:2018-05-22 03:10:23
【问题描述】:
我想在“if-statement”中写一个脚本
./simulations/文件夹中有很多.html文件,在html文件中写end balance如下:
'期末余额:1000.00000000 (0.00%)'
'期末余额:19.21977440 (-98.08%)'
'期末余额:1135.80974233 (13.58%)'
我只想找到'期末余额:....... (...%)'
如果结束余额为1000或更低 echo 'end balance 100 0r lwss',如果更高,'echo end balance greater than 1000'。
像这样:
if [ "$(egrep -n 'end balance: [0-9.]' ./simulations/*.html)" -gt 1000 ]; then
echo ' end balance bigger than 1000 '
else
echo ' end balance less than 1000 '
fi
【问题讨论】:
-
这个脚本有什么问题/错误?
标签: bash shell if-statement grep