#!/bin/bash
if [ -s file.txt ]
then
echo "File is empty"
else
count=1
cat file.txt | while read line
do
echo "$line"
count=$(( $count + 1 ))
done
fi
if [ -f file.txt ]; then
if [ -s file.txt ]; then
echo "file.txt is not empty
else
echo "file.txt is empty"
fi
else
echo "file.txt doesn't exists"
fi
if [[ $(stat -c "%s" file.txt) -eq 0 ]]; then
echo "file.txt is empty"
else
echo "file.txt doesn't exist or not empty"
fi
if [ -s file.txt ] then echo "File is empty"
-s FILE
FILE exists and has a size greater than zero
if [ -f file.txt -a ! -s file.txt ]