In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the method of Linux to calculate the number of Chinese pieces in the directory, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
In Linux, we can use the ls command + wc command to calculate the number of files in a directory.
The command ls is used to list the contents of the directory; the wc command is used to calculate the numeric lines and characters in the file, and you can count the lines when used with-l.
To calculate the number of files in a directory, you need to use the following syntax:
# ls-1 | wc-l
Let's break down the grammar and see what it does.
● ls: listing files
●-1: this is one. It prints one entry per line. To print a hidden file, change it to-1a
● |: pipe output to.
● wc: counting word count
●-l: show only the number of rows
Example: let's take an example to see how these commands work.
Create a new directory, test_folder, and navigate to it.
# mkdir test_folder & & cd test_folder
Next, we will create some text files
# touch file1.txt file2.txt file3.txt file4.txt file5.txt
Let's confirm the existence of the file by listing them with the ls command
# ls-l
Output:
We use the wc command + ls command to calculate the number of files in this directory:
# ls-1 | wc-l
Output:
The above are all the contents of the method of calculating the number of pieces in the directory by Linux. Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.
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.