The UNIX and Linux Forums
>
Top Forums
>
UNIX for Dummies Questions & Answers
Sort by size, then list file in each directory
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Sort by size, then list file in each directory
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
1
(
permalink
)
07-01-2009
ChatPerdu
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...
ChatPerdu
View Public Profile
Find all posts by ChatPerdu
Find ChatPerdu's past nominations received
Find ChatPerdu's present nominations given