<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux labs on Nerdsid.com</title><link>https://nerdsid.com/labs/linux/</link><description>Recent content in Linux labs on Nerdsid.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 30 Jun 2026 11:41:54 +0000</lastBuildDate><atom:link href="https://nerdsid.com/labs/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Practical Grep: Filtering Errors and Patterns in Log Files</title><link>https://nerdsid.com/labs/linux/practical-grep-filtering-errors-and-patterns-in-log-files/</link><pubDate>Tue, 30 Jun 2026 11:41:54 +0000</pubDate><guid>https://nerdsid.com/labs/linux/practical-grep-filtering-errors-and-patterns-in-log-files/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>This walkthrough covers using grep to search and filter log files for errors, specific requests, and multi-pattern matches.&lt;/p>
&lt;h2 id="tasks">Tasks&lt;/h2>
&lt;ol>
&lt;li>Find all &lt;code>ERROR&lt;/code> messages in &lt;code>system.log&lt;/code> and count how many there are.&lt;/li>
&lt;li>Find all lines containing &lt;code>POST&lt;/code> requests in &lt;code>access.log&lt;/code>.&lt;/li>
&lt;li>Find all lines in &lt;code>application.log&lt;/code> that contain both &lt;code>WARNING&lt;/code> and &lt;code>query&lt;/code> (case-insensitive).&lt;/li>
&lt;li>Search for all user authentications (containing &lt;code>User authenticated&lt;/code>) across all log files.&lt;/li>
&lt;/ol>
&lt;h3 id="requirements">Requirements&lt;/h3>
&lt;ul>
&lt;li>Use &lt;code>grep&lt;/code> for all searches (combining with other commands like &lt;code>wc&lt;/code> where needed).&lt;/li>
&lt;li>Save each task&amp;rsquo;s output to its own file: &lt;code>task1_output.txt&lt;/code>, &lt;code>task2_output.txt&lt;/code>, &lt;code>task3_output.txt&lt;/code>, &lt;code>task4_output.txt&lt;/code>.&lt;/li>
&lt;li>Original log files must not be modified.&lt;/li>
&lt;/ul>
&lt;h2 id="solution">Solution&lt;/h2>
&lt;h3 id="task-1">Task 1&lt;/h3>






&lt;div class="codeblock">
 &lt;div class="codeblock__header">
 &lt;div class="codeblock__filename codeblock__filename--lang">
 
 BASH
 
 &lt;/div>
 &lt;div class="codeblock__actions">
 
 &lt;/div>
 &lt;/div>
 &lt;div class="codeblock__body">
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -c &lt;span class="s2">&amp;#34;ERROR&amp;#34;&lt;/span> system.log &amp;gt; task1_output.txt&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
 &lt;/div>
&lt;/div>&lt;p>&lt;code>grep -c&lt;/code> counts the number of matching lines instead of printing them. Redirecting the output saves the count to task1_output.txt.&lt;/p></description></item></channel></rss>