If a file is empty then it must print the message "no data found"
eg:
if [cat $FILE_NAME = empty ] then
echo "no data found"
your help is really appreciated.
If a file is empty then it must print the message "no data found"
eg:
if [cat $FILE_NAME = empty ] then
echo "no data found"
your help is really appreciated.
There is a test option for this:
if [ ! -s FILE ]; then
echo "No data found..."
fi
If you want to test for empty file (without any non printable characters or white spaces):
[ -s afile ] || echo empty
Otherwise:
[ -n "$(<afile)" ] || echo empty
Thanks for the help it worked
if [ ! -s FILE ]; then echo "No data found..." fi