To list the size of a directory in Bash, you can use the du (disk usage) command. This command provides information about the space used by files and directories.
Basic Usage:
du -sh /path/to/directory
Explanation:
du: The command to check disk usage.-s: Summarizes the total size of the specified directory.-h: Makes the output human-readable (e.g., KB, MB).
Example:
To check the size of a directory named project in your home directory, you would run:
du -sh ~/project
Output:
The command will return something like:
2.3M /home/labex/project
This indicates that the project directory uses 2.3 megabytes of disk space.
If you want to see the sizes of all subdirectories within a directory, you can omit the -s option:
du -h /path/to/directory
Feel free to ask if you need more details or examples!
