-r file check if file is readable.
-w file check if file is writable.
-x file check if we have execute access to file.
-f file check if file is an ordinary file (as opposed to a
directory, a device special file, etc.)
-s file check if file has size greater than 0.
-d file check if file is a directory.
-e file check if file exists. Is true even if file is a
directory.
-w file check if file is writable.
-x file check if we have execute access to file.
-f file check if file is an ordinary file (as opposed to a
directory, a device special file, etc.)
-s file check if file has size greater than 0.
-d file check if file is a directory.
-e file check if file exists. Is true even if file is a
directory.
example:
if [ -s file ]
then
such and such
fi
then
such and such
fi
for more info, go here http://www.tldp.org/LDP/abs/html/fto.html
1 comment:
Thanks for posting the useful test operators. For more file test operators check the following link:
file test operators in unix bash script
Post a Comment