ls -l |grep "^-"|wc -l //Verified that redhat is easy to use
or
find ./company -type f | wc -l
View the number of files in a folder, including subfolders.
ls -lR|grep "^-"|wc -l
View the number of folders in a folder, including subfolders.
ls -lR|grep "^d"|wc -l
illustrate:
ls -l
The long list outputs the file information in the directory (note that the files here are different from ordinary files, which may be directories, links, device files, etc.)
grep "^-"
Here, part of the output information of the long list is filtered, and only general files are retained. If only the directory is retained, it is ^d
wc -l
Count the number of lines of output information, because only general files have been filtered, so the statistical result is the number of lines of general file information, and because
One line of information corresponds to one file, so it is the number of files.
l
Linux check folder sizedu -sh View the current folder size
du -sh * | sort -n Count the size of the current folder (directory) and sort by file size
du -sk filename View the specified file size