"Linux" Statistics command WC

Source: Internet
Author: User

If I want to know/etc/man.config, how many words are there in this file? How many lines? How many characters can you do? Can actually use WC this command to achieve Oh! He can help us calculate the overall data of the output information!

[Email protected] ~]#WC[-LWM] Options and Parameters:-L: only travel;-W: Lists only how many words (English word);-m: how many characters; example one: the/etc/MansHow many related words, lines, and characters are there in. config? [[Email protected]~]#Cat/etc/Mans. config |WC     141     722    4617# The output of the three numbers, respectively, represents: "Line, word count, number of characters" example two: I know to use LastCan output the lander, but LastThe last two lines are not the account contents, then how can I get the total number of times of this month's landing system by a line of command string? [[Email protected]~]# Last|grep[A-za-z] |grep-V'wtmp'|WC-L # because Lastwill output blank lines with wtmp words at the bottom two lines, so I use #grepTake out non-blank lines, and remove wtmp line, in the calculation of the number of rows, you can understand!

WC can also be used as an order? This is not the WC in the bathroom! This is quite useful for calculating file content for a tool group Oh! For example, use this method when you want to know how many accounts are currently in your account file: "cat/etc/passwd | Wc-l "! Because/ETC/PASSWD is a representative of the user! So knowing the number of rows will know how many accounts are in the inside! And if you want to count the number of characters in a file, use the WC-M option!

  References: HTTP://VBIRD.DIC.KSU.EDU.TW/LINUX_BASIC/0320BASH.PHP#WC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.