6 WC Command Examples to Count Number of Lines, Words, Characters in Linux

If you have any questions or problems regarding this article and want help within 24 Hours? Ask Now

Support TecMint: Did you find this tutorial helpful?. Please help to keep it alive by donating. Every cent counts! - Donate Now

Ravi Saive

Simple Word a Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

6 Responses

  1. Sunny says:

    cat filename.txt | grep -v “saerch” | sed -n ‘ $ p ‘

  2. Saransh says:

    If u don’t want to print to print the last line

    Go for grep -v option

    can try grep -v ‘^6’

  3. Jayanto says:

    When I do a wc -l in a directory then the output is something like –
    1 File1.txt
    2 File2.txt
    3 File3.txt
    6 Total

    I do not want to display the last Total. How can we do that? Any insights..!

    • You can try this

      wc file*|grep -v total

      grep with -v option removes the lines which have the word “total” in them., so except last line all files with word count will shown. Hope it helps

  4. SRI says:

    Please tell me how to display number of words in each line by using wc command?

    • while read line; do echo “$line” | wc -m ;done < filename

      if your file contains '/' then use 'read -r' in the above command

      Another simple way without wc is

      awk '{print length($0) }' filename

Leave a Reply

Your email address will not be published. Required fields are marked *

Join Over 85000+ Linux Users
  1. 53,676
  2. 2,838
  3. 20,639

Enter your email to get latest Linux Howto's