×

wc command: Demonstrated with 5 examples on Ubuntu 20.04 LTS

This article will guide you on how to use the #wc #command in #Linux. Here you will learn the basics of wc command along with its command-line options and few practical examples. Now you can easily count number of lines, words, characters and bytes in your files and in the output from other commands. The wc command in #UNIX is a command line utility for printing newline, word and byte counts for files. It can return the number of lines in a file, the number of characters in a file and the number of words in a file. It can also be combine with pipes for general #counting operations. To use use WC command, you need to know the following: 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. 1. A Basic Example of WC Command. 2. Count Number of Lines. 3. Display Number of Words. 4. Count Number of Bytes and Characters. 5. Display Length of Longest Line.