![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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, |
|
||||
|
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
Let us know, does this helped ! |
|
||||
|
Quote:
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:
|
|
||||
|
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
Arun |
|
||||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|