Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Write a script to display the directory in the descending order of the size of each file.


clear
echo "ENTER DIR"
read dir
`echo ls -lS $dir` > file.txt
len=`cat file.txt | wc -l`
i=2
echo "SIZE          FILENAME"
echo "====       ==============="
while [ $i -le $len ]
do
  record=`ls -lS $dir | head -n $i | tail -n 1`
  # record=`cat file.txt | head -n $i | tail -n 1`
  filename=`echo $record | cut -d " " -f 9`
  size=` echo $record | cut -d " " -f 5`
  echo "$size        $filename" 
  i=`expr $i + 1`
done 

Output:

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes