In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the wc command on the Linux system. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
In the Linux system, wc (world count) is a command to count the number of words, bytes and lines in a file, which can help us to count the above information very conveniently.
1. Command format:
Wc [options] file...
2. Command function:
Count the number of bytes, words and lines in the specified file, and display the statistical results to output. This command counts the number of bytes, words, and lines in the specified file. If no file name is given, it is read from standard input. Wc also gives the presidential count of the specified file.
3. Command parameters:
C counts the number of bytes.
-l count the number of rows.
-m counts the number of characters. This flag cannot be used with the-c flag.
-w count the word count. A word is defined as a string separated by white space, tabbed, or newline characters.
-L prints the length of the longest line.
-help displays help information
-version displays version information
4. Use an example:
Example 1: view the number of bytes, words and lines of a file
Command:
Wc test.txt output:
$cat test.txt hello world! [work@] $wc test.txt 5 5 18 test.txt [work@] $wc-c test.txt 18 test.txt [work@] $wc-l test.txt 5 test.txt [work@] $wc-m test.txt 18 test.txt [work@] $wc-w test.txt 5 test.txt [work@] $wc-L test.txt 5 test.txt description:
5 5 18 test.txt
Number of lines, words, bytes, file name
Example 2: how to print only statistics but not file names with wc command
Command:
Output:
[work@] $wc-l test.txt 5 test.txt [work@] $cat test.txt | wc-l 5 description:
Using pipe lines, | represents pipes and represents the output of the previous command as a parameter to the next command, which is especially useful when writing shell scripts.
Example 3: used to count the number of files in the current directory
Command:
Ls-l | wc-l
Output:
[work@] $ll total 22112 drwxrwxr-x+ 2 work work 4096 Aug 6 22:37. Drwxrwxr-x+ 6 work work 4096 Aug 1 10:54.. -rw-rw-r--+ 1 work work 1633 Aug 211: 17 get_plain_model_simple.py-rw-rw-r--+ 1 work work 5421191 Aug: 19 model-rw-rw-r--+ 1 work work 17138517 Aug: 38 plain_model-rw-rw-r--+ 1 work work 76 Aug 1 11:02 test_function.sh-rw-rw-r--+ 1 work work 907 Aug 211: 16 test _ getFeatureContent.py-rw-rw-r--+ 1 work work 1805 Aug 2 11:37 test_get_plain_model_simple.py-rw-r--r--+ 1 work work 12288 Aug 2 11:54. Test _ get_plain_model_simple.py.swp-rw-rw-r--+ 1 work work 18 Aug 6 22:37 test.txt [work@] $ls-l | wc-l 8 description:
The quantity contains the current directory
Thank you for reading! This is the end of this article on "how to use wc commands in Linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.