In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what is the role of the wc command in linux. I hope you will gain something after reading this article. Let's discuss it together.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
In linux, the function of the wc command is to count the number of bytes, words, and lines in the specified file, and display the output of the statistical results. If you do not specify the file name, or if the file name given is "-", the wc command will read data from the standard input device; the command uses the syntax "wc [options] file."
The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.
The Linux wc command is used to count the word count.
Using the wc instruction, we can calculate the number of Byte, words, or columns of a file. If the file name is not specified, or if the file name is given as "-", the wc instruction will read data from the standard input device.
Syntax:
Wc [options] file.
Parameters:
-c or-- bytes or-- chars displays only the number of Bytes.
-l or-- lines displays the number of rows.
-w or-- words displays only the number of words.
-- help online help.
-- version displays version information.
Specific usage and analysis
The following is to demonstrate the specific usage and analysis of the above option parameters of the wc command through a specific file, and create a test.txt file, as shown in the following figure:
1) after executing the command wc-c test.txt, the result is as follows:
As the figure shows, the file shows 24 bytes because it includes a space character and a newline character for each line.
We can view the newline characters by command cat-A test.txt, as shown in the following figure:
2) after executing the command wc-l test.txt, the result is as follows:
The figure shows that the file has three lines
3) after executing the command wc-m test.txt, the result is as follows:
The result is the same as the parameter result of the-c option, with 24 characters
4) after executing the command wc-w test.txt, the result is as follows:
The figure shows that the file has four words.
5) after executing the command wc-L test.txt, the result is as follows:
The figure shows that the longest line length of the file is 11, excluding newline characters.
6) after executing the command wc test.txt, the result is as follows:
The result in the figure is the number of lines, words, bytes, and file name.
4. The above is the detailed usage of parameter options for the wc command, which is also used with pipe characters in practical applications, which is very useful when writing shell scripts. The following examples are given:
1) after executing the command ls-l in the root directory, you can see the print message as shown in the following figure:
2) execute the command ls-l | wc-l in the root directory, and the result is as follows:
The result shows that the statistics ls-l command displays 20 lines.
After reading this article, I believe you have a certain understanding of "what is the function of wc command in linux". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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
After downloading and installing the GHOST software
© 2024 shulou.com SLNews company. All rights reserved.