Headlines
Loading...
Program in UNIX - File size to be displayed

Program in UNIX - File size to be displayed

Write a script which reports names and sizes of all files in the directory (directory would be supplied as an argument to the shell script) whose size is exceeding 1000 bytes. The filenames should be printed in descending order of their sizes. The total number of such files should be reported.
rm temp
echo "Enter directory name"
read dname
for i in `ls -S $dname`
do
   s=`ls -l $dname|grep $i$| cut -c37-42`
   if [ $s -gt 1000 ]
   then
        echo $i:$s>>temp
   fi
done
echo "SORTED BY FILE SIZE"
sort -t":" -rn  +1 temp
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***