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
How to list a file size, but not its name? ordano UNIX for Dummies Questions & Answers 2 02-12-2009 02:00 AM
command to list file size rgordon HP-UX 3 12-05-2007 05:43 AM
List File size komputersman UNIX for Dummies Questions & Answers 10 06-13-2007 04:39 PM
File size limitation of unix sort command. cskumar Shell Programming and Scripting 7 10-07-2005 10:37 AM
list file's by size order in sepecfied directory and sub directories ferretman UNIX for Dummies Questions & Answers 2 01-03-2002 07:55 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2009
ChatPerdu ChatPerdu is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 2
Sort by size, then list file in each directory

Hi,

I have directories with name like:
aaa
bbb
ccc
...

I would like to to see which directories are the largest and then list the files within each. I have success using:

Code:
du -ks * | sort -rin | head -n 20
which gives me an output like:
120 bbb
27 ccc
3 aaa
...

I would like to be able to do a simple "ls" so I have a clearer view of what's in each of the big directory. Without knowing anything about xargs, I am trying:

Code:
du -ks * | sort -rin | head -n 20 | xargs ls
which gives me (on top of the errors) an alphabetical order list of "ls", instead of what I would like which is more like a "-exec ls {}" in "find"...

ls: 3: No such file or directory
ls: 120: No such file or directory
ls: 27: No such file or directory
aaa:
will_cover_page.gif

bbb:
will_dependents_page_2.gif will_dependents_page_4.gif
will_dependents_page_3.gif

ccc:
will_dependents_page_1.gif will_signatures.gif

Is there a more efficient way of doing this? Thanks in advance...
  #2 (permalink)  
Old 07-01-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Code:
find /path/to/directories -type d -size +20 |
while read dirname
     ls -l $dirname
done > outputfile
Change the 20 (blocks) to whatever size suits you.
  #3 (permalink)  
Old 07-01-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
even this will do i guess...
Code:
find /path/to/directories -type d -size +20 |xargs ls -lrt
  #4 (permalink)  
Old 07-01-2009
ChatPerdu ChatPerdu is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 2
For:
Code:
find . -type d -size +2
I get this:
.
./99584B685FF3/bbb.app
./D3B9BA1F472/www.app
./830F3FF6E3F9/Documents
./A754A83053D/www.app
...
For some reason, it finds stuff one directory lower... "99584B685FF3" is the directory I am aiming for, so I tried
Code:
find . -type d -size +2 -maxdepth 1
I get:
. Shouln't it be something like ./99584B685FF3

and for
Code:
find . -type d -size +2 -maxdepth 2
.
./99584B685FF3/bbb.app
./D3B9BA1F472/www.app
./830F3FF6E3F9/Documents
./A754A83053D/www.app
...

What could be the reason. I initially thought directories were just "special files" in UNIX and do not have a size. But the "Documents" shown is really a directory.

Thanks for suggesting but still no go. Furthermore, I am losing all the size sorting - largest directory first

Last edited by ChatPerdu; 07-01-2009 at 05:40 PM.. Reason: wrong info posted
Sponsored Links
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 02:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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