The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find largest files tonijel Shell Programming and Scripting 12 09-11-2009 09:28 AM
How to find the list of 5 largest file in current directory? salman4u UNIX for Dummies Questions & Answers 4 01-28-2009 04:11 AM
find the 5o largest files in a directory igidttam Filesystems, Disks and Memory 8 05-16-2007 02:20 PM
list largest files in a directory & its subdirectories igidttam UNIX for Dummies Questions & Answers 6 09-25-2006 12:31 PM
largest size directory in unix arunkumar_mca UNIX for Advanced & Expert Users 5 09-30-2005 02:04 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-23-2009
Pouchie1 Pouchie1 is offline
Registered User
  
 

Join Date: May 2009
Posts: 41
Best way to find largest files in a directory

What is the best way to find the largest files in a directory? I used du -k|sort -rn |less.

I got a results for this. But if I used the following command , I got another result...a different order in the same directory. Why is that?

ls -la |awk '{print $5," ",$9}' sort -rn|less. I saw that this command takes into consideration the zip file while du does not.

Thanks,
  #2 (permalink)  
Old 09-23-2009
daPeach daPeach is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 63
simply
Code:
ls -S | head -1
  #3 (permalink)  
Old 09-23-2009
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 453
Different ways has different advantages & disadvantages such as some of the above will not go recursively, and some of them will not consider files and show only dirs.

To overcome all those, use find command as
Code:
find . -type f -exec ls -s {} \; | sort -n -r | head -5
I hope you can understand the above, if need to simple edits to fit your need.

Let us know, does this helped !
  #4 (permalink)  
Old 09-24-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,175
Quote:
ls -la |awk '{print $5," ",$9}' sort -rn|less
You probably want "ls -l" rather than "ls -la" to avoid processing "." and "..".
Also, because you have sorted with the highest at the top (-r) you probably want "more" not "less". On my system the sort "-n" (numeric) switch needs to be before the "-r" reverse switch. Also, there is a pipe missing in your command line.

Try:
Quote:
ls -l |awk '{print $5," ",$9}' | sort -n -r | more
  #5 (permalink)  
Old 09-24-2009
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
there is also a simple way to find the largest file

Code:
  ls -lrt | sort +4n | tail
HTML Code:
  ls -lrt  -- will sort the file based on list and recent time modified
  sort +4n  -- will sort the ls -lrt output based on the column 4 which is size
  tail -- will give you the last 10 lines , if you use tail -1 then you will 
                    get the largest file alone
Thanks
Arun
  #6 (permalink)  
Old 4 Weeks Ago
Pouchie1 Pouchie1 is offline
Registered User
  
 

Join Date: May 2009
Posts: 41
Thanks very much everybody. The help is much appreciated.
  #7 (permalink)  
Old 4 Weeks Ago
proactiveaditya proactiveaditya is offline
Registered User
  
 

Join Date: Sep 2009
Location: Kolkata,India
Posts: 136
Linux Find Large Files
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0