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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

wc: command not found

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.

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.

If you encounter the below error while running the wc command:

wc: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

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 

7. Count all lines, words and bytes from `stdin`:

# find . | wc

8. Count the length of the longest line in number of characters:

# wc --max-line-length path/to/file

Filed Under: Linux

Some more articles you might also be interested in …

  1. lsusb Command Examples in Linux
  2. CentOS / RHEL 7 : How to modify Network Interface names
  3. fprintd-delete Command Examples in Linux
  4. What is an equivalent of which on the Windows command line?
  5. How to use sudo to allow a non-root user run a particular command
  6. calcurse Command Examples in Linux
  7. lsb_release: command not found
  8. arp Command Examples in Linux
  9. When to use rescan-scsi-bus.sh -i (LIP flag) in CentOS/RHEL
  10. How to change the default permissions on /var/log/audit/audit.log file in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright