Maxim Markov
Maxim Markov

Reputation: 43

how to display size of folders MacOS via du

I'm trying to display size of subfolders in my Download forlder via:

du -sh

output isL

6.2G    .

Is there any way to display it as:

folder1    1.2G
folder2    0.2G
folder3    2.6G
folder4    5.9G

But without any subfolders (I don't need to see size of all folders into folder1, folder2, folder3 )

Upvotes: 4

Views: 3131

Answers (3)

RavinderSingh13
RavinderSingh13

Reputation: 133750

Following may also help you which will help you to:

I- Have a variable in this command so that you could pass any directory name there.

II- You could set level till you want to see the folder.

III- structure's details. It will give output in size's increasing order.

du  "$val" -hk --max-depth=2 | sort -nr

Upvotes: 0

qwertmax
qwertmax

Reputation: 3450

you have to use command like this:

du -h -d 1 | sort -hr

you should get output:

1.2G    folder1
0.2G    folder2
2.6G    folder3
5.9G    folder4

Upvotes: 4

iBug
iBug

Reputation: 37307

This is what you want:

du -hd 1

Sample output (on Ubuntu 16.04, du (GNU coreutils) 8.25):

1.2G    ./folder1
200M    ./folder2
2.6G    ./folder3
5.9G    ./folder4
9G      .

Upvotes: 1

Related Questions