Write a shell script to all files whose size is greater than specific size.

Write a shell script to all files whose size is greater than specific size.

Code:

clear
echo -------------------------------
echo '\tFile List'
echo -------------------------------
echo Enter the file size
read s1
echo Files list whose size is greater than $s1 bytes size.
for File in *
do
        if [ -f $File ]
        then
        s2=$(stat -c %s $File)

        if [ $s2 -gt $s1 ]
        then
                echo $File
        fi
       fi
done

Output:

------------------------------- 
File List 
------------------------------- 
Enter the file size 
1025 
Files list whose size is greater than 1025 bytes size. 
f1 
satheesh1.pls 
yuvan.pls 

No comments

Powered by Blogger.