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 !!

LinkBacks (?)
LinkBack to this Thread: http://www.unix.com/unix-dummies-questions-answers/53240-unix-shell-script-finding-top-ten-files-maximum-size.html
Posted By For Type Date
terjeo's Bookmarks on Delicious This thread Refback 12-26-2008 11:06 AM

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Finding cumulative size of files older than certain days rohan076 Shell Programming and Scripting 1 04-28-2008 01:07 PM
shell script to find files by date and size dadadc UNIX for Dummies Questions & Answers 1 10-20-2007 05:18 AM
Maximum size of a file in unix nagalenoj UNIX for Dummies Questions & Answers 3 08-16-2007 09:56 AM
finding duplicate files by size and finding pattern matching and its count jerome Sukumar Shell Programming and Scripting 2 12-01-2006 04:20 AM
bash script working for small size files but not for big size files. davidpreml Shell Programming and Scripting 1 11-01-2006 11:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack (1) Thread Tools Search this Thread Rate Thread Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-13-2008
abhilashnair abhilashnair is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 13
Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories.
Please suggest any ideas
  #2 (permalink)  
Old 02-13-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Quote:
Originally Posted by abhilashnair View Post
I need to write a Unix shell script
You don't need a "script", it fits into a single line:

find /start/dir -type f -exec du {} \; | sort -rn | head -10

bakunin
  #3 (permalink)  
Old 02-13-2008
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 255
Thanks it is listing , But the size that shows when i run ls -l command and the size that is showing for this command is different can you please let me know the reason

example :

$ ll /pfta02/10.001
-rw-rw-rw- 1 pnt pf 87843360 Feb 6 02:21 /pfta02/10.001

$ find /pfta03 -type f -exec du {} \; |sort -rn | head -1
171572 /pfta02/10.001

why the size listing is as 171572 instead of 87843360 ... IS any convertion happening ?..
  #4 (permalink)  
Old 02-13-2008
maheshwin maheshwin is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 55
ls -l will give the output of the total directory links , so dont trust it, du is the exact form to get the info, above commands are perfectly true
  #5 (permalink)  
Old 02-13-2008
abhilashnair abhilashnair is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 13
I tried the command but I am getting following output for all files in the entire dir tree

find: /dir/filename: Value too large to be stored in data type
  #6 (permalink)  
Old 02-14-2008
abhilashnair abhilashnair is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 13
Any thoughts on this?
  #7 (permalink)  
Old 02-14-2008
sb008 sb008 is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 384
Quote:
Originally Posted by abhilashnair View Post
I tried the command but I am getting following output for all files in the entire dir tree

find: /dir/filename: Value too large to be stored in data type

Use "du -h", it will report the size in a human readable form.

However, this will make the sort a bit more complex.

To maintain the sort as it is, use "du -k" which reports in kbytes instead of blocks, meaning the output numbers will be half as big.
Closed Thread

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 05:22 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