Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux count the number of files

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Linux how to count the number of documents related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have a harvest after reading this Linux how to count the number of documents, let's take a look.

Count the number of files in the current directory (excluding directories)

$ls-l | grep "^ -" | wc-l counts 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 subdirectories)

$ls-lR | grep "^ d" | wc-l command parsing:

Ls-l long list outputs the file information under this directory (note that the files here refer to directories, links, device files, etc.), each line corresponds to a file or directory, and ls-lR lists all files, including subdirectories.

Grep "^ -" filters the output of ls, leaving only general files and directories as grep "^ d".

Wc-l counts the number of lines of output information, the statistical result is the number of lines of output information, one line of information corresponds to a file, so it is the number of files.

This is the end of the article on "how Linux counts the number of files". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to count the number of documents in Linux". If you want to learn more knowledge, you are welcome to follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report