<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rafael Chefe on Medium]]></title>
        <description><![CDATA[Stories by Rafael Chefe on Medium]]></description>
        <link>https://medium.com/@rafaelchefe?source=rss-d04ef1777495------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*e0u89n_k-LH1id4Z.</url>
            <title>Stories by Rafael Chefe on Medium</title>
            <link>https://medium.com/@rafaelchefe?source=rss-d04ef1777495------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:16:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rafaelchefe/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Epic grep]]></title>
            <link>https://medium.com/@rafaelchefe/epic-grep-684f9a53078a?source=rss-d04ef1777495------2</link>
            <guid isPermaLink="false">https://medium.com/p/684f9a53078a</guid>
            <category><![CDATA[grep]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tools]]></category>
            <dc:creator><![CDATA[Rafael Chefe]]></dc:creator>
            <pubDate>Wed, 04 May 2016 01:16:55 GMT</pubDate>
            <atom:updated>2016-05-20T00:08:04.695Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello folks! It’s my first post here on Medium!</p><p>Well, let’s get to business:</p><p>Here’s a quick tip that made my head explode. It may sound silly, but I swear I didn’t knew how to to this, and it made my life so much better.</p><p>Consider the following (rather silly) text:</p><pre>first line<br>second line<br>third line<br>fourth line<br>fifth line<br>sixth line<br>seventh line<br>eighth line<br>ninth line<br>tenth line</pre><p>Everybody knows (or at least should know) how to use grep to match lines from a text file:</p><pre>$ grep fifth example.txt <br>fifth line</pre><p>Well, I recently discovered that there is a way to print lines <strong>around</strong> the ones we match. The <strong>-n</strong> option prints n lines <strong>before and after</strong> the match:</p><pre>$ grep -3 fifth example.txt <br>second line<br>third line<br>fourth line<br>fifth line<br>sixth line<br>seventh line<br>eighth line</pre><p>The -<strong>An</strong> option prints n lines <strong>after</strong> the match:</p><pre>$ grep -A3 fifth example.txt <br>fifth line<br>sixth line<br>seventh line<br>eighth line</pre><p>The <strong>-Bn</strong> option prints n lines <strong>before</strong> the match:</p><pre>$ grep -B3 fifth example.txt <br>second line<br>third line<br>fourth line<br>fifth line</pre><p>Is this cool or what?!?</p><p>Now a real world example. Let’s get some requests from a Rails log file:</p><pre>$ grep GET development.log <br>Started GET &quot;/&quot; for 127.0.0.1 at 2013-11-04 21:42:27 -0200<br>Started GET &quot;/&quot; for 127.0.0.1 at 2013-11-04 21:42:34 -0200<br>Started GET &quot;/games&quot; for 127.0.0.1 at 2013-11-04 21:42:52 -0200</pre><pre>...</pre><p>Okay, but what happens after each request??</p><pre>$ grep GET -A4 development.log</pre><pre>Started GET “/” for 127.0.0.1 at 2013–11–04 21:42:27 -0200<br> ActiveRecord::SchemaMigration Load (0.2ms) SELECT “schema_migrations”.* FROM “schema_migrati<br>ons”<br>Processing by Rails::WelcomeController#index as HTML<br> Rendered /home/chefe/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/templates/rails/welcom<br>e/index.html.erb (2.6ms)<br>Completed 200 OK in 48ms (Views: 11.5ms | ActiveRecord: 0.0ms)<br> — <br>Started GET “/” for 127.0.0.1 at 2013–11–04 21:42:34 -0200<br>Processing by Rails::WelcomeController#index as HTML<br> Rendered /home/chefe/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/templates/rails/welcom<br>e/index.html.erb (0.1ms)<br>Completed 200 OK in 2ms (Views: 1.8ms | ActiveRecord: 0.0ms)</pre><pre> — <br>Started GET “/games” for 127.0.0.1 at 2013–11–04 21:42:52 -0200<br>Processing by GamesController#index as HTML<br> Game Load (0.2ms) SELECT “games”.* FROM “games”<br> Rendered games/index.html.erb within layouts/application (1.9ms)<br>Completed 200 OK in 973ms (Views: 970.5ms | ActiveRecord: 0.2ms)</pre><p>Now we know! Awesome! =)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=684f9a53078a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>