In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Linux system how to count the number of files under the folder", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "how to count the number of files under the folder in the Linux system"!
One is:
The code is as follows:
Ls-l | grep "^ -" | wc-l
Description:
Ls-l long list outputs the file information under this directory (note that the files here are different from ordinary files, which may be directories, links, device files, etc.)
Grep ^-here we filter part of the long list output information and keep only the general files. If we only keep the directory, it is ^ d.
Wc-l statistics the number of lines of output information, because it has been filtered to only general files, so the statistical result is the number of lines of general file information, and because one line of information corresponds to a file, that is, the number of files.
View the number of files under the folder (the number of files in the current directory and subfolders)
The code is as follows:
Find. /-type f | wc-l
Or
The code is as follows:
Ls-lR | grep "^ -" | wc-l
The other is:
The code is as follows:
Ls-alR dir_name | awk'{if (NF > 2&&substr)! = "d") print $0}'| wc-l
The strange thing is that there is a slight difference in the number of files counted by the two methods, and the latter is slightly more than the previous one, but there is little difference, which can be used as a reference.
Thank you for your reading, the above is the content of "how to count the number of files under the folder in the Linux system". After the study of this article, I believe you have a deeper understanding of how to count the number of files under the folder in the Linux system. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.