![]() ![]() The ‘ wc‘ command allows an argument ‘ -L‘, it can be used to print out the length of the longest ( number of characters) line in a file. When using option -c will print the number of bytes of a file. ![]() When using option -m with the wc command will print the total number of characters in a file. Type the following command to count the words in a file. The -w argument with the wc command prints the number of words in a file. In the output, the first field is assigned as count and the second field is the name of the file. Say, the following command will display the count of newlines in a file. Count Number of Lines in a FileĬount the number of newlines in a file using the option ‘ -l‘, which prints the number of lines from a given file. $ wc tecmint.txt 12 16 112 tecmint.txt 2. The three numbers shown below are 12 ( number of lines), 16 ( number of words), and 112 ( number of bytes) of the file. The ‘ wc‘ command without passing any parameter will display a basic result of the ‘ tecmint.txt‘ file. Let’s find out the output of the tecmint.txt file using the cat command as shown below. We have used the ‘ tecmint.txt‘ file for testing the commands. Let’s see how we can use the ‘ wc‘ command with the few available arguments and examples in this article. wc -L – prints only the length of the longest line in a file.wc -m – prints the count of characters from a file.wc -c – Displays the count of bytes in a file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |