Write a shell script to check whether the given file is empty or not.

echo "Enter file name"
read fn

if [ -f $fn ]
then
    if [ -s $fn ]
    then
        echo "File exists and not empty"
    else
        echo "File exists and empty"
    fi
else
    echo "File not exists"
fi

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *