Команда du
Tells you how much space a file occupies.
du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories
| -a | Displays the space that each file is taking up. |
| -k | Write the files sizes in units of 1024 bytes, rather than the default 512-byte units. |
| -s | Instead of the default output, report only the total sum for each of the specified files. |
| -d | Do not cross filesystem boundaries. For example, du -d / reports usage only on the root partition. |
| -L | Process symbolic links by using the file or directory which the symbolic link references, rather than the link itself. |
| -o | Do not add child directories' usage to a parent's total. Without this option, the usage listed for a particular directory is the space taken by the files in that directory, as well as the files in all directories beneath it. This option does nothing if -s is used. |
| -r | Generate messages about directories that cannot be read, files that cannot be opened, and so forth, rather than being silent (the default). |
| -x | When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand. |
| directories | Specifies the directory or directories. |
du -s *.txt - Would report the size of each txt file in the current directory. Below is an example of the output.
8 file1.txt
8 file2.txt
10 file3.txt
2 file4.txt
8 file5.txt
8 file6.txt
du -ch *.txt - Display the size of the txt files in a friendly size format listing as well as the total capacity of all the files combined.