mercredi 4 février 2015

bash script - I want to check if XLS is empty. if it is, i don't want to do anything. If it is not, I want to do something

I have a bash script that has an if-then-fi statement included. the code block executes only when the XLS is not empty. Currently i'm evaluating this by utilizing the following:



FILESIZE = `wc -c < $FILENAME`


it seems that the default filesize generated is 4096 bytes if the file is empty. So...



if [ $FILESIZE -gt "4096" ]; then
do something
fi


however, my boss isn't a huge fan of hard coded numbers. is there an alternative solution to seeing whether an XLS has data?


thanks!


Aucun commentaire:

Enregistrer un commentaire