Solved

Linux script or command to read top 50 file size

Posted on 2014-09-09
7
322 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need BIOS update Linux for MSI X99A motherboard. 4 41
centos linux 65 125
ignore other .htaccess 2 44
Quickest way to query Windows Event ID from a Linux Device 3 28
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
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.

776 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