Write a script to Check whether file is empty or not, And if file name doesn‟t exist than print appropriate message.

SOLUTION....

#!/bin/bash
# Script to check whether file is empty or not

echo "Enter file name:"
read fname

if [ -e "$fname" ]; then
    if [ -s "$fname" ]; then
        echo "✅ File '$fname' exists and is NOT empty."
    else
        echo "⚠️ File '$fname' exists but is EMPTY."
    fi
else
    echo "❌ File '$fname' does not exist."
fi

OUTPUT

Leave a Reply

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

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.