table of Contents
1. Check the remaining space of the disk
2. View the folder/file partition (mount point)
4. List all file sizes in the folder
5. List designated files and count the number of designated files
1. Check the remaining space of the disk
df -lh
2. View the folder/file partition (mount point)
df <file (folder) path>
3. View the folder/file size
du log2012.log shows the space occupied by the specified file
du -m scf view the space occupied by the specified directory
du -s only displays the size of the sum
du -h test in a format that is easy to read
du -ah test files and directories are displayed
du -c log30.tar.gz log31.tar.gz shows the size of the disk space occupied by each, and counts their total size
du|sort -nr|more sort by size
du -h --max-depth=1 output the space used by each subdirectory in the current directory
du -m xx.txt #Display the size in M units
ls -lh xx.txt
4. List all file sizes in the folder
ls -l #View file size in K
ls -lh #View file size in M
ll -h #View file size in G
ls -lhS #Sort by big to small
5. List designated files and count the number of designated files
(1) View the number of files in the current directory (including files in subdirectories) Note: R stands for subdirectories
ls -lR|grep "^-"| wc -l
(2)# View the number of files in the current directory (excluding files in subdirectories)
ls -l|grep "^-"| wc -l
(3)# View the number of folder directories in the current directory (excluding directories in subdirectories), the same as above, if you need to view subdirectories, add R
ls -l|grep "^d"| wc -l
(4) Count the number of all files in all directories beginning with "20161124"
ls -lR 20161124*/|grep "^-"| wc -l
grep "^d" means directory, "^-" means file