| Matt Benson 2005-03-16, 6:02 pm |
| I want to perform a couple of statements if either the file does not exist OR the file size of a given file
is equal 0. Currently the best solution I can imagine is something like:
if [! -e myfile.dat ]; then
echo "File not existing or file size = 0"
do_something
else
filesize=`wc -c myfile.dat`
echo "filesize=$filesize"
if [ $filesize = 0 ]; then
echo "File not existing or file size = 0"
do_something
fi
fi
The first problem I encounter is that the back ticks are NOT recognized by the shell interpreter.
filesize contains blank after the wc command. Why?
Is there a filesize testing without back quotes instructions?
Secondly, I feel that there is a (much) shorter way of doing this.
Has someone a better idea?
Thx
Matt
|