In Unix, I used to do something like:

>du / | sort -rn | less

which does a disk usage by directory starting at the root (or whatever directory you put in), then sorts them in reverse order by the number of blocks each directory takes, and prints them out through a pager (less, or more, depending on your system).

The idea is to find the directories that are taking up a lot of space so I can focus my disk cleanup efforts.

Tried that in Windows, but the sort command does not have an argument to sort numerically (e.g., to sort 10 as greater than 9).

But the BASH in the GIT package implements a number of the unix commands, including du and sort, so I tried it there, and it worked great, except that, if it's not run as an administrator, it's denied access to a lot of the directories.

Now, here's the surprising thing: If I run GIT-BASH as administrator, it takes the "-rn" of the sort argument as an input file name to sort, rather than command arguments. Anybody know how come, or if there's some other character to use to denote command arguments when running as Administrator?

Thanks.

EDIT: Okay, I'm baffled. It's working this morning exactly as expected. I don't know what the problem was yesterday.

The command line was (run from root of the C: drive under Win 7, when starting Git-Bash as Administrator.

du | sort -rn | less

Only difference is, this morning I explicitly added the directory:

du /c | sort -rn | less
link|improve this question

44% accept rate
what is the exact command line you try? – user377178 Jan 19 at 18:50
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.