6

This is what I tried:

[demo@ ~]# ll /usr/local/apache2/logs/|xargs |du -hm -
du: cannot access `-': No such file or directory

I want to see the amount of space each file occupies in m unit.

How to do it the correct way?

Nicolas Kaiser
  • 165
  • 1
  • 4
  • 16
kernel
  • 8,211
  • 5
  • 18
  • 14
  • possible dupplicate of: http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size – quanta Aug 31 '11 at 11:15

4 Answers4

5

I'm assuming ll is an alias for ls -l, in which case what's wrong with

du -hm /usr/local/apache2/logs/*
MadHatter
  • 78,442
  • 20
  • 178
  • 229
1
du -s /usr/local/apache2/logs/* | sort -rn | cut -f2 | xargs -d '\n' du -sh
quanta
  • 50,327
  • 19
  • 152
  • 213
0

Ok, not exactly what you asked for, but tree -fis or tree -fih might help you a bit and is a small, compact solution. :)

The first command outputs the recursive directory tree showing also the file size in bytes, the second one is the same but has "human readable" output, showing the size in kilobytes, megabytes, gigabytes... whatever it considers appropriate for that file.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • This isn't a bad solution, but note that the `tree` command **is not** universal -- in fact none of the systems I looked at (FreeBSD, Debian, OS X) have it. – voretaq7 Aug 31 '11 at 16:55
  • Well, it's universal in a way that it's available for practically all the Linux/BSD systems :) – Janne Pikkarainen Aug 31 '11 at 17:45
0

Are you trying not to descend into subdirectories?

How about:

find . -type f -maxdepth 1 |xargs du -m 

Pipe to "sort -n" if desired.

cjc
  • 24,533
  • 2
  • 49
  • 69