1
2
3
4
5
6
7
|
myFile=
/home/test/file
.txt
size=`
wc
-c $myFile |
cut
-d
' '
-f1`
if
[ $size -
eq
0 ];
then
echo
"File $myFile is empty!"
else
echo
"File $myFile is not empty."
fi
|
或者:
1
2
|
myFile=
/home/test/file
.txt
[ -e $myFile ] &&
echo
"File $myFile is empty!"
||
echo
"File $myFile is not empty."
|