Forrest logo
back to the du tool


numfmt: Convert to IEC units, pad with 5 characters, left aligned.
$ du -s * | numfmt --to=${iec} --format="${%-5f}"
try on your machine

This command is used to display the size of files and directories in the current directory in a more readable format. Here's an explanation of each part of the command:

  • du -s *: The du command is used to estimate and summarize file and directory space usage. The -s option tells du to only display the total size of each argument (file or directory) rather than breaking it down by individual files. * is a wildcard that matches all files and directories in the current directory. So, this part calculates the size of each item in the current directory.

  • |: The pipe operator (|) is used to redirect the output of the previous command as the input for the next command.

  • numfmt: This is a command used to format numbers. It can be used to convert numbers to different units or format them in a specific way.

  • --to=${iec}: The --to option of numfmt specifies the unit to which the numbers should be converted. In this case, ${iec} is likely a variable that holds the value iec, which stands for International Electrotechnical Commission. It is a formatting option that uses binary units (such as KiB, MiB, etc.) instead of decimal units (KB, MB, etc.) for more accurate representation.

  • --format="${%-5f}": The --format option specifies how the numbers should be formatted. ${%-5f} is a formatting string that tells numfmt to format the numbers with a minimum width of 5 characters, left-aligned, and using floating-point notation. The -5 part ensures that the output is aligned properly even with varying sizes of numbers.

Overall, this command calculates the sizes of all files and directories in the current directory, then converts and formats those sizes using the numfmt command to display them in a more readable and standardized format using binary units.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the du tool