How do I get the total size of everything in a directory in one line?

AGamePlayer

I know I can use du -h to output the total size of a directory. But when it contains other subdirectories, the output would be something like:

du -h /root/test

.
.
.
.
24K   /root/test/1
64K   /root/test/2
876K  /root/test/3
1.1M  /root/test/4
15M   /root/test/5
17M   /root/test

I only want the last line because there are too many small directories in the /root/test directory. What can I do?

John

Add the --max-depth parameter with a value of 0:

du -h --max-depth=0 /root/test

Or, use the -s (summary) option:

du -sh /root/test

Either of those should give you what you want. For future reference, man du is very helpful.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I get the size of a directory on the command line?

From Dev

How do I determine the total size of a directory (folder) from the command line?

From Dev

How do I determine the total size of a directory (folder) from the command line?

From Dev

How to get directory total size?

From Dev

How do I get total Qty using one linq query?

From Dev

How do you get the total size of all files of a certain type within a directory in linux?

From Dev

How can I get the total size of .conf extension in directory /etc and save them into another file?

From Dev

How do i get the output in one line as a string?

From Dev

How To Get Total Line Count From All Text Files In A Directory

From Dev

How To Get Total Line Count From All Text Files In A Directory

From Dev

How do I get total physical memory size using PowerShell without WMI?

From Dev

How do I count multiple overlapping strings and get the total occurences per line (awk or anything else)

From Dev

How do I fill everything over a straight line and under a curve?

From Dev

How do I extract everything from the start of a line to a specific string?

From Dev

How do i get the total average?

From Dev

Regex, how do I say, match everything but one word?

From Dev

wget (or something) to get total size of directory?

From Dev

How do I find the total running time of videos in a directory?

From Dev

How can I get total size of particular folder in C#?

From Dev

How can I get total size of particular folder in C#?

From Dev

How do I get my command line utility to update one line instead of printing multiple lines?

From Dev

How do I get my command line utility to update one line instead of printing multiple lines?

From Dev

How do I output the acronym on one line

From Dev

Get total size of file in current directory (not include size of subdirectory)

From Dev

How do i copy files from one directory to another directory?

From Dev

How do I symlink each of the files in one directory to another directory?

From Dev

How do I get project root directory?

From Dev

How do I get the current directory of the prompt

From Dev

How do I get an entire directory in sftp?

Related Related

  1. 1

    How do I get the size of a directory on the command line?

  2. 2

    How do I determine the total size of a directory (folder) from the command line?

  3. 3

    How do I determine the total size of a directory (folder) from the command line?

  4. 4

    How to get directory total size?

  5. 5

    How do I get total Qty using one linq query?

  6. 6

    How do you get the total size of all files of a certain type within a directory in linux?

  7. 7

    How can I get the total size of .conf extension in directory /etc and save them into another file?

  8. 8

    How do i get the output in one line as a string?

  9. 9

    How To Get Total Line Count From All Text Files In A Directory

  10. 10

    How To Get Total Line Count From All Text Files In A Directory

  11. 11

    How do I get total physical memory size using PowerShell without WMI?

  12. 12

    How do I count multiple overlapping strings and get the total occurences per line (awk or anything else)

  13. 13

    How do I fill everything over a straight line and under a curve?

  14. 14

    How do I extract everything from the start of a line to a specific string?

  15. 15

    How do i get the total average?

  16. 16

    Regex, how do I say, match everything but one word?

  17. 17

    wget (or something) to get total size of directory?

  18. 18

    How do I find the total running time of videos in a directory?

  19. 19

    How can I get total size of particular folder in C#?

  20. 20

    How can I get total size of particular folder in C#?

  21. 21

    How do I get my command line utility to update one line instead of printing multiple lines?

  22. 22

    How do I get my command line utility to update one line instead of printing multiple lines?

  23. 23

    How do I output the acronym on one line

  24. 24

    Get total size of file in current directory (not include size of subdirectory)

  25. 25

    How do i copy files from one directory to another directory?

  26. 26

    How do I symlink each of the files in one directory to another directory?

  27. 27

    How do I get project root directory?

  28. 28

    How do I get the current directory of the prompt

  29. 29

    How do I get an entire directory in sftp?

HotTag

Archive