Solved

Linux script or command to read top 50 file size

Posted on 2014-09-09
7
323 Views
Last Modified: 2014-09-10
Dear Experts,

Since my disk-space is used more than 95%, Could you provide  linux
command or script to find out the top 50 biggest files size in my hard-disk so that I can delete those
not-important files with bigger file size. I check du and df command not including that .

Please advise
0
Comment
Question by:rwniceing
  • 4
  • 3
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40313773
ls -sR / | perl -MHeap::Simple -lne 'BEGIN{ $heap = Heap::Simple->new(elements => "Array")}m#^(/.*):# and $d=$1; m/^(\d+)\s+(.*)/ and $heap->insert([$1,"$d/$2"]) and print "$1 $d/$2"; $heap->count>50 and $heap->extract_top;END{print "@$_" for  $heap->extract_all;} '
0
 
LVL 1

Author Comment

by:rwniceing
ID: 40313798
ozo, thanks for your reply. I get this error on linux Centos when run the command  on linux shell
Can't locate Heap/Simple.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.16.2/x86_64-linux /usr/local/lib/perl5/site_perl/5.16.2 /usr/local/lib/perl5/5.16.2/x86_64-linux /usr/local/lib/perl5/5.16.2 .).
BEGIN failed--compilation aborted.
0
 
LVL 1

Author Comment

by:rwniceing
ID: 40313800
Or do I need to run it in script with including perl ?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40313808
You could install it, or use a slightly less efficient method:
ls -sR / | perl -lne 'm#^(/.*):# and $d=$1; m/^(\d+)\s+(.*)/ and print "$1 $d/$2"' | sort -n | tail -50
0
 
LVL 1

Author Comment

by:rwniceing
ID: 40313815
it works but including  all directory from root , how can I  just do it  for my account directory  such as "/home/myaccount" ?
0
 
LVL 84

Expert Comment

by:ozo
ID: 40313830
ls -sR /home/myaccount
0
 
LVL 1

Author Closing Comment

by:rwniceing
ID: 40313837
thanks for your rely ,now I know what  you mean  and following command works

ls -sR /home/myaccount | perl -lne 'm#^(/.*):# and $d=$1; m/^(\d+)\s+(.*)/ and print "$1 $d/$2"' | sort -n | tail -50
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question