Linux/Unix — Checking Word Counts with wc

There are times when you need to know the number of lines that match a search string.

The wc command can be used to count the lines that it receives. For example, the following command lists how many hits in an Apache log file come from a specific IP address:

$ grep /var/log/httpd/access-log | wc -l

The wc command has other uses as well. By default, wc prints the number of lines, words, and bytes in a file:

$ wc /var/log/dmesg

This command list counts for a single file

$ wc /var/log/*.log

With this command you may list single/totals for many files located into the path mentioned.


About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on March 16, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: