Du Sort By Size
I need to get a list of human readable du output.However, du does not have a 'sort by size' option, and piping to sort doesn't work with the human readable flag.For example, running: du sort -n -rOutputs a sorted disk usage by size (descending): du sort -n -r65108.61508./dir32056./dir41032./dir1508./dir2However, running it with the human readable flag, does not sort properly: du -h sort -n -r508K./dir264M.61M./dir32.1M./dir41.1M./dir1Does anyone know of a way to sort du -h by size? As far as I can see you have three options:. Alter du to sort before display. Alter sort to support human sizes for numerical sort.
Post process the output from sort to change the basic output to human readable.You could also do du -k and live with sizes in KiB.For option 3 you could use the following script: #!/usr/bin/env pythonimport sysimport resizeRe = re.compile(r'^(d+)(.)$')for line in sys.stdin.readlines:mo = sizeRe.match(line)if mo:size = int(mo.group(1))if size.
For obtaining the size in KB of present directorydu -sk.If on Solaris 10du -sh. 'unixten via solaris-l' 4/23/2008 10:18 AM how to display directory size in solaris?NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this communication is not the intended recipient or the employee or agent responsible for delivering the communication, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me immediately by replying to this email.REMINDER: The disclosure of medical information is strictly prohibited by federal regulation. Unauthorized release of medical information may result in administrative, civil and criminal sanctions.
Du Sort By Size Top 10
- Du -BM -max-depth=1 sort -nr Caveat: This displays everything in Megabytes, so the smallest unit you will see is 1M. If you need to see it in Kilobytes just change the 'M' to a 'K'.
- Nov 5, 2016 - One of the easiest ways to sort with out the -h option of sort is to first use the du command with out the -h option, sort that output and then run du again on the sorted list of folders. In the above example, the du prints the size in bytes, after which it is sorted numerically.
Du Command Sort By Size Linux
Du -h -max-depth=1 sort -hr - (Sort subdirectories by size Prints the sizes of all the subdirectories (sorted by size), similar to Treesize utility.