View the current directory size and number of files under Centos

Check the size of the directory and the files it contains
du -ch directory
Check the number of files in the current directory 
ls -l | grep "^-" | wc -l

Check the number of files suffixed with .jpg in the current directory 
ls -l | grep ".jpg" | wc -l
to view the number of files in the current directory (including subdirectories)
ls -lR | grep "^-" | wc -l
to view the number of folders (directories) in a directory (including subdirectory)
ls -lR| grep "^d" | wc -l
Parameter description:
ls -l
outputs the file information in the directory in the form of a long list, including directories, links, device files, etc.
grep "^-"
filters part of the long list output information, and only keeps general files. If only the directory is kept, it is ^d
wc -l

Number of lines of statistics output

Reprint address: https://blog.csdn.net/rudygao/article/details/27701927

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325811324&siteId=291194637