Weblog entry #5 for HWilton
But i couldnt find the proper grep syntax to do that.
Filtering the du -mc output to echo only lines that has one slash, would do the trick ... but how ?!
du -mc | grep "/"the last command isnt filtering anything (obviously)
And man grep gives cryptic help on the subject :
A regular expression may be followed by one of several repetition oper-
ators:
? The preceding item is optional and matched at most once.
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
{n} The preceding item is matched exactly n times.
{n,} The preceding item is matched n or more times.
{n,m} The preceding item is matched at least n times, but not more
than m times.
i've tried
du -mc | grep "/"{1}
but doesnt output anything at all, then
Comments on this Entry
du --max-depth=1 and if you like human readable megabytes and gigabytes, du -h --max-depth=1
[ Parent | Reply to this comment ]
du --max-depth=1 -mcCheck the manpage. (I had du version 5.97)
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
du -shfor getting the size of whole directory,
du -sh *for listing also file and 1st level directory sizes.. in this way you can use
du -sh */for your purpose. The drawback is that it doesn't list hidden files and directories.. but you can use it when you are sure that there aren't any in the directory :) And the last one, often used by me:
du -sk * | sort -n
[ Parent | Reply to this comment ]
The advantage of wld3's solution is you can use your shell globbing patterns to refine which parts of the tree are selected. For instance, if you're using zsh, you can get a size summary excluding tmp and backup directories to a depth of one like this:
du -shc */*^tmp^backup
[ Parent | Reply to this comment ]