Bash du Command File/Folder Size

Check File/Folder Size with Bash du Command

This article introduces how to check file/folder size with the Bash du command in Linux PC/server command lines. &nbsp; <li>Example of outputting only files/folders over 1000M bytes du -am | awk... If you want to know the total capacity of a folder for now...

Shou Arisaka
1 min read
Nov 25, 2025

This article introduces how to check file/folder size with the Bash du command in Linux PC/server command lines.

  • Example of outputting only files/folders over 1000M bytes
``` du -am | awk '{if($1 > 1000){print $1, $2}}' ```
  • Ignore error output and output files/folders over 3GB to standard output + file output
``` du -am 2>/dev/null | awk '{if($1 > 3000){print $1, $2}}' |& tee ~/lib/output.log

2>/dev/nullโ†’ Ignore error output like cannot read directory / Permission denied.

<ul>
 	<li>If you want to know the total capacity of a folder for now</li>
</ul>

user@pc:/mnt/c/share/anime$ du -h 62G ./watched 1.7G ./_anime 9.6G ./_movie 26G ./_yet 181G .

<ul>
 	<li>If you want to know folder sizes (don't output folders under 1GB and errors)</li>
</ul>

du -hm 2>/dev/null | awk โ€˜{if($1 > 1000){print $1, $2}}โ€™

<ul>
 	<li>Want to know the total capacity of the current directory</li>
</ul>

du -h |tail -1


Reference:

[ใ€ du ใ€‘ Display file capacity in directory](http://itpro.nikkeibp.co.jp/article/COLUMN/20060227/230748/)

Share this article

Shou Arisaka Nov 25, 2025

๐Ÿ”— Copy Links