Sunday, December 2, 2012

Find Out File Size Using Shell Script | Shell Programming



Write shell script to to know whether the size of the file provided is greater than zero or zero and print size of file.

Find Out File Size Using Shell Script | Shell Programming


This is small script to finding out provided filename size whether it exist or not and if it then findout its size in Byte and print its size using stat -c%s $filename command.



#!/bin/bash
#Progran to Check Size Of File greater than zero or not
#Program from Nullpointer.in
echo "Please Enter File Name:"
read filename 
if [ -f $filename ]
then
size=`stat -c%s $filename`
if [ size>0 ]
then
echo "File size is greater than Zero"
echo "File Size is => $size"
else
echo "File Size is equal to zero"
fi
else
echo "File Doesn't Exist......!!!!!"
fi

0 comments:

Post a Comment