• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

wc command in Linux with Examples

{{postValue.id}}

wc command in Linux with Examples

wc command in Unix/Linux operating systems is used to find out number of line count, word count, byte and characters count in a files specified by the file arguments. This tutorial explains the wc command in detail.

Syntax

The syntax for wc command with its options are

wc [options] filenames

Usage of the commands

  • wc -l : Prints the number of lines in a file.
  • wc -w : prints the number of words in a file.
  • wc -c : Displays the count of bytes in a file.
  • wc -m : prints the count of characters from a file.
  • wc -L : prints only the length of the longest line in a file.

Let us start with textfile.odt file you can use text files,pdf,..etc.

wc Command without any options

Run the following command to display the basic result of textfile.odt file.

[root@linuxhelp Desktop]# wc textfile.odt 
48   270 12286 textfile.odt

In the output 48 is no of lines, 270 is no of words, 12286 is no of bytes.

Using wc command with &ndash l options

The below command is used to Count only Number of Lines in the file.

[root@linuxhelp Desktop]# wc -l textfile.odt 
48 textfile.odt

Using wc command with &ndash w options

The below command helps to Count only Number of words in the file.

[root@linuxhelp Desktop]# wc -w textfile.odt 
270 textfile.odt

To Count Number of Bytes and Characters

The below command is used to Count only Number of Bytes in the file.

[root@linuxhelp Desktop]# wc -c textfile.odt 
12286 textfile.odt

The below command Count only Number of characters in the file.

[root@linuxhelp Desktop]# wc -m textfile.odt 
8065 textfile.odt

Using wc command with &ndash L options

The below command is used to print out the length of longest line in a file.

[root@linuxhelp Desktop]# wc -L textfile.odt 
999 textfile.odt

To Check the version wc command

Using the following command, you can check the version of wc command.

[root@linuxhelp Desktop]# wc --version
wc (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html> .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Rubin and David MacKenzie.

Tags:
benjamin
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to find byte counts for any file using the "wc" count?

A

You can use the option of '-c" with "wc" command to find byte counts for any file using the "wc" count. For syntax: "wc -c fine.txt"

Q

How to find the new lines count in any file using the "wc" command?

A

You can use the option of "-l" with "wc" command to find the new lines count in any file using the "wc" command. For syntax: "wc -l file.txt".

Q

How can I check the version of "wc" command in Linux?

A

You can run the following command to check the version of "wc" command in Linux. For Syntax: "wc -V".

Q

How to find the length of the longest line in any file using the "wc" command?

A

Use the option of "-L" with "wc" command to find the length of longest line in any file using the "wc" command. For syntax: "wc -L file.txt".

Q

How to fetch the wrod counts in certain file using the "wc" command?

A

You can use the option of "-w" with "wc" command to fetch the wrod counts in certain file using the "wc" command. For syntax: "wc -w file.txt".

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.