• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

wc Command Examples in Linux

by admin

The word count (wc) command is used to count the number of lines, words, and characters in a text file. If multiple files are specified, then the command displays the counts for each file and the total count for all files.

wc command examples in Linux

Syntax

The syntax of the wc command is:

# wc [options] {file names}

wc Command Options

The wc command provides various options that enable you to specify the nature of the output.

Option Used To
-c Display the byte count.
-m Display the character count.
-l Display the newline count.
-w Display the word count.

wc Command Examples

1. To see no of lines from a file:

# wc -l test.txt 

2. To count the bytes:

# wc -c test.txt 

3. To get no of characters:

# wc -m test.txt 

4. To get the no of words:

# wc -w test.txt 

5. To get the length of longest line:

# wc -L test.txt 

6. To get the version:

# wc --version 

Filed Under: Linux

Some more articles you might also be interested in …

  1. Installation Steps of jEdit on Ubuntu Linux
  2. kvm-img: command not found
  3. How to make ethtool settings persistent across reboots in CentOS / RHEL 6,7
  4. CentOS / RHEL : Managing password ageing for users using chage (with practical Examples)
  5. Complete Guide to Configuring iSCSI in CentOS / RHEL 7
  6. How to Rebuild GRUB on MSDOS Partition Type in CentOS/RHEL/OEL 7
  7. CentOS / RHEL 7 : How to enable telnet for a group of users
  8. How to recreate LVM device files under /dev directory using vgmknodes
  9. ac Command Examples in Linux
  10. Linux OS service ‘portmap’

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright