How can I perform size check of any character file(which switch)?
For example: I have to perform certain actions if file size is not zero. How can I do that?
Is this syntax fine?
if test ! -z $filename
then
fi
How can I perform size check of any character file(which switch)?
For example: I have to perform certain actions if file size is not zero. How can I do that?
Is this syntax fine?
if test ! -z $filename
then
fi
-z $filename checks whether the string contained in the variable $filename is of length zero or not.
If you understand string functions in c/c++, -z $filename is the same is as the function if (strlen(filename) == 0)
To check whether the file has a size greater than 0, use the construct
[ -s "$filename" ]
vino
Thanks for your help vino.
malay