Linux view directory number and size

1. View the number of files in a directory

1. View the number of files in the directory

That is, how many files are there in the current directory/hdapp directory, folders are not included in the value

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

The following command folder also takes into account the value

ls | wc -w

2. View the number of files in the specified directory

If the specified directory is omitted, it is the default current directory

ls -l /指定目录 | grep "^-"| wc -l

3. Recursively query the number of files in the current directory

Recursively search all files in all folders in the current directory

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

4. Recursively query the number of files in the specified directory

Recursively search all files in all folders in the specified directory

ls -lR /指定目录 | grep "^-"| wc -l

Second, view the file size in a directory

1. View the file size in the current directory

du -sh

2. View the file size in the specified directory

du -sh /指定目录

3. View the specified file size

du -sh /指定目录/指定文件

Guess you like

Origin blog.csdn.net/weixin_42039228/article/details/131161815