如果文件为空,这将通知我们:
[[ ! -s $file ]] && echo "hello there I am empty file !!!"
但是如何检查一个文件是否有空格(空格或制表符)?
发布于 2020-02-29 19:00:48
类似于其他答案,但使用否定的grep -q
if ! grep -q '[^[:space:]]' "$file"; then
echo "file is empty"
else
echo "File has data"
fi
https://unix.stackexchange.com/questions/386499
复制相似问题