Solved

Linux script or command to read top 50 file size

Posted on 2014-09-09
7
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

691 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