Comments on: 6 Wc Command to Count Number of Lines, Words, and Characters in File https://www.tecmint.com/wc-command-examples/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Tue, 23 Jan 2024 04:31:04 +0000 hourly 1 By: Ravi Saive https://www.tecmint.com/wc-command-examples/comment-page-1/#comment-2128725 Tue, 23 Jan 2024 04:31:04 +0000 http://www.tecmint.com/?p=2278#comment-2128725 In reply to T-T-T.

@TTT

If you want to count the occurrences of the line “01:19:21” in a text file using a Linux command, you can use the following command:

grep -c "01:19:21" data.txt

This will output the number of lines in the file that contain “01:19:21”.

]]>
By: Vincent Ypma https://www.tecmint.com/wc-command-examples/comment-page-1/#comment-2128624 Mon, 22 Jan 2024 18:01:59 +0000 http://www.tecmint.com/?p=2278#comment-2128624 In reply to T-T-T.

The command is attempting to filter and count the lines containing the string “01:19:21” in a text file or a stream of text.

$lines_of_text | grep 01:19:21
]]>
By: Ashley https://www.tecmint.com/wc-command-examples/comment-page-1/#comment-1332077 Wed, 06 May 2020 16:12:44 +0000 http://www.tecmint.com/?p=2278#comment-1332077 In reply to Thomas.

The previous cut | grep | wc still only counts lines, not word occurrences, and would consider “anthem,” “these,” etc matches for the substring “the.”

This is a way to do what you want-

# perl -lne '$c += () = /\bthe\b/g; END{ print $c }' YourFileGlob ListofFiles
]]>
By: Ravi Saive https://www.tecmint.com/wc-command-examples/comment-page-1/#comment-1155424 Tue, 21 May 2019 04:19:34 +0000 http://www.tecmint.com/?p=2278#comment-1155424 In reply to Thomas.

@Thomas,

To count occurrence of word in Linux text file, you should use following command.

# cut -f 1 filename | grep -i "Yourword" | wc -l
]]>
By: Thomas https://www.tecmint.com/wc-command-examples/comment-page-1/#comment-1155402 Tue, 21 May 2019 03:37:20 +0000 http://www.tecmint.com/?p=2278#comment-1155402 Is there a way to see how many times the word ‘the’ was used?

]]>