Solved

Linux script or command to read top 50 file size

Posted on 2014-09-09
7
316 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now