Methods linux view folder size, number of files

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_44266650/article/details/99414168

Under linux view the file size and the number of

ls -l |grep "^-"|wc -l

or

find ./company -type f | wc -l

View a folder under the file number, including subfolders inside.

ls -lR|grep "^-"|wc -l

View a folder number folder, including sub-folders inside.

ls -lR|grep "^d"|wc -l

Description:

ls -l

The output of the long list of directory file information (file note here, different from the general file, the directory may be, the link device file, etc.)

grep "^-"

Here the long list of output information filtering part, leaving only the general document, if only to preserve the directory is

wc -l

The number of rows of statistical output, as it has been filtered leaving only the general file, so the statistics is the number of lines general file information, and because
the number of line information corresponding to a file, so it is file.

Linux查看文件夹大小
du -sh 查看当前文件夹大小
du -sh * | sort -n 统计当前文件夹(目录)大小,并按文件大小排序
du -sk filename 查看指定文件大小

When the disk size will exceed the standard alarm, then if the master command df and du is a very wise choice.

df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。
du可以查看文件及文件夹的大小。

Combination of the two to use, very effective. For example, to view a directory with df which is too large, then df view folders or file size, so you can quickly identify the crux.

Guess you like

Origin blog.csdn.net/weixin_44266650/article/details/99414168