Counting Occurrences
Part of the Fundamentals section of Coddy's Terminal journey — lesson 51 of 82.
Challenge
EasyYou've filtered the errors, but now you need to know exactly how many there are. Counting occurrences is essential for understanding the severity of issues in your logs.
Use a pipeline to count how many ERROR entries exist in server.log. Combine grep with wc -l to get the count.
grep "ERROR" server.log | wc -lYour output should be a single number representing the total count of error entries.
Tip: The
wc -lcommand counts lines. When piped aftergrep, it counts how many lines matched your search pattern. In the final lesson, you'll save these findings to a report file.
Try it yourself
grep "ERROR" server.logAll lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective10Log Analyzer Project
Project OverviewViewing The Log File2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data Pipeline