The Linux “wc” command is an abbreviation for phrase count. The command is applied to rely the amount of traces, words and phrases, bytes, and even people and bytes in a text file. In this tutorial, we search at the Linux “wc” command and demonstrate functional illustrations of its usage.
The Linux “wc” command can take the adhering to syntax:
The “wc” command, in its standard variety, displays the output in a columnar format, as demonstrated in the snippet down below.
Let’s briefly examine what every column signifies:
Column 1: Displays the range of traces present in the text file. As observed from the output, the file has seven lines. Be encouraged that this accounts for both equally the blank and the non-blank traces.
Column 2: This prints the term count.
Column 3: This displays the amount of bytes in the file.
Column 4: This is the file title of the textual content file.
Move Many Files as Arguments in A single Command
The “wc” command can also consider several files in one command and exhibit the figures of every file on a separate file. Suppose you have two files, like in our case in point where we have two textual content documents — fruits.txt and veggies.txt.
In its place of employing the “wc” command two times to look at the stats of just about every file, you can use the subsequent syntax to settle for each documents as arguments.
For our example, to rely the amount of lines, words and phrases, and bytes in every file, operate the following command:
$ wc fruits.txt veggies.txt
From the output, you can see that the “wc” command displays the output of equally files in a columnar output. The result of each file is put on a different row, and the incredibly past row supplies the total count for the lines, words, and bytes of the two documents.
Count the Variety of Traces Only in a File
Let’s look at the text file hello.txt that we started out with. Let’s recap the line, term, and character count as follows:
The -l alternative is used to count the number of lines only.
Print Word Rely Only in a File
To show the phrase rely in a text file, use the -w option as follows. This is rather easy, and as you can see, it counts the range of words only contained in the file.
Rely the Variety of Bytes only in a File
To print the quantity of bytes only in a file, use the -c choice as offered in the command beneath:
Count the Variety of Figures Only in a File
In addition, you can count the amount of characters by passing the -m solution as offered in the command underneath:
For a lot more command solutions and usage of the “wc” command, be absolutely sure to verify the gentleman webpages:
If you are intrigued in examining the edition, simply invoke the simple command:
The Linux “wc” command is a genuinely uncomplicated and simple-to-use command that offers you a clue on the amount of strains, words and phrases, bytes, and figures contained in a file. For any queries, do get in contact. We will endeavor to give a prompt response.