how to use wc command with its examples

This command is generally used for processing the file data, in terms of length, character, bytes, line size etc. It is mostly used along with other commands to process the files and to understand their nature to take further actions accordingly. Like sometime we may need a configuration file should not have any line more than 1024 charaters, in that case this command becomes useful to analyze the files. It prints newline, word, and byte counts for each file. It comes from “coreutils-8.4” package.

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

Leave a Reply

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