<分区>
我有一个简单的命令来识别文件何时为空但不起作用
MN=$(echo "$(cat empty)") ;
if [ MN == "" ]; then echo "This file is empty"; else echo "This file has been edited. You'll need to do it manually."; fi
我做错了什么
请帮帮我
<分区>
我有一个简单的命令来识别文件何时为空但不起作用
MN=$(echo "$(cat empty)") ;
if [ MN == "" ]; then echo "This file is empty"; else echo "This file has been edited. You'll need to do it manually."; fi
我做错了什么
请帮帮我
最佳答案
test -s
测试文件是否存在且非空。
if test -e empty && ! test -s empty; then
echo "This file exists but is empty"
fi
关于linux - 如果文件在 linux bash 中为空,我如何获得回显输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44057500/