Filtering Errors
Part of the Fundamentals section of Coddy's Terminal journey — lesson 50 of 82.
Challenge
EasyNow let's filter the log to find only the error entries. Errors are critical issues that need attention, so being able to quickly extract them from a log file is an essential skill.
Use grep to display only the lines from server.log that contain ERROR.
grep "ERROR" server.logYour output should show the three error entries from the log file.
Tip: The
grepcommand is case-sensitive by default. Since our log uses uppercaseERROR, make sure to match that exactly. In the next lesson, you'll learn to count these filtered results.
Try it yourself
head -n 5 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