<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhinav Kumar</title>
    <description>The latest articles on DEV Community by Abhinav Kumar (@abhinav).</description>
    <link>https://dev.to/abhinav</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F30716%2F49336dd3-889e-4a52-a298-16e5c946ad87.jpg</url>
      <title>DEV Community: Abhinav Kumar</title>
      <link>https://dev.to/abhinav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhinav"/>
    <language>en</language>
    <item>
      <title>Keep your SSH sessions alive until you don't want to</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Sat, 23 May 2020 20:43:17 +0000</pubDate>
      <link>https://dev.to/abhinav/keep-your-ssh-sessions-alive-until-you-don-t-want-to-15n2</link>
      <guid>https://dev.to/abhinav/keep-your-ssh-sessions-alive-until-you-don-t-want-to-15n2</guid>
      <description>&lt;p&gt;I do almost all of my work remotely on a server. I as well as my colleagues have a ton of SSH sessions open at all times. And I have seen them getting frustrated when they take a break and come back to see the terminal tab not responding.&lt;/p&gt;

&lt;p&gt;This is very easy to fix though. We just have to tell the SSH daemon at the server or the client in our system to send packets at a specific interval to avoid that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration on the server
&lt;/h2&gt;

&lt;p&gt;In the config of OpenSSH server in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;, add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ClientAliveInterval 300
ClientAliveCountMax 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will make sure that the OpenSSH server keeps the all the connections alive with no effort on the part of the clients.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration on the client
&lt;/h2&gt;

&lt;p&gt;Add the following lines to any of the SSH configs in your system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host *
    ServerAliveInterval 300
    ServerAliveCountMax 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should add this to &lt;code&gt;/etc/ssh/ssh_config&lt;/code&gt; for system-wide change or &lt;code&gt;~/.ssh/config&lt;/code&gt; to apply just for the current user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Per-Host Configuration
&lt;/h3&gt;

&lt;p&gt;You can replace &lt;code&gt;*&lt;/code&gt; in &lt;code&gt;Host *&lt;/code&gt; with a hostname to only apply the configuration for connections to that specific server. e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host *abhnv.dev
    ServerAliveInterval 300
    ServerAliveCountMax 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation for the settings
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ServerAliveInterval 300&lt;/code&gt; or &lt;code&gt;ClientAliveInterval 300&lt;/code&gt; means that the server or the client will send a null packet to the other end every 300 seconds.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ServerAliveCountMax 3&lt;/code&gt; or &lt;code&gt;ClientAliveCountMax 3&lt;/code&gt; means that the server or the client will try 3 times before giving up.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally posted at &lt;a href="https://abhnv.dev/blog/2020-05-24-ssh-keep-alive/"&gt;https://abhnv.dev/blog/2020-05-24-ssh-keep-alive/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>openssh</category>
      <category>programming</category>
      <category>remote</category>
    </item>
    <item>
      <title>Bump up the number of files your system can monitor for changes</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Mon, 18 Nov 2019 12:49:40 +0000</pubDate>
      <link>https://dev.to/abhinav/inotify-limit-4jfi</link>
      <guid>https://dev.to/abhinav/inotify-limit-4jfi</guid>
      <description>&lt;p&gt;Have you ever been working on a project and realized that project is not being hot-reloaded or re-compiled when you save or have auto-save enabled.&lt;/p&gt;

&lt;p&gt;I almost always run into this issue after I have set up a new development environment. It seems like the system just stops monitoring for files. I have only encountered this issue on Linux systems though. Never on Windows or macOS.&lt;/p&gt;

&lt;p&gt;After a bit of googling, I found out that the default limit of file watchers count, that Linux systems allow to monitor for filesystem changes is very low. 8192 to be exact. I know that it is very reasonable for a normal user. But not for a development use case. Our workspace's file count is usually upwards of 8192. JavaScript projects? Even more so.&lt;/p&gt;

&lt;p&gt;The most common way, applications like VSCode or IntelliJ IDEs monitor filesystem changes on Linux, is &lt;code&gt;inotify&lt;/code&gt;. We can query the current limit by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/fs/inotify/max_user_watches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see a value in thousands, this is your problem. Fortunately, it's very trivial to fix. No kernel compilation needed. 😋&lt;/p&gt;

&lt;p&gt;This limit configuration can be set by changing the value of &lt;code&gt;fs.inotify.max_user_watches&lt;/code&gt; in &lt;code&gt;/etc/sysctl.conf&lt;/code&gt;. You can put it to any number you want but I think ~65000 is a good enough limit. I set it to 65536 because Base 2!&lt;/p&gt;

&lt;p&gt;You can do this using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;fs.inotify.max_user_watches&lt;span class="o"&gt;=&lt;/span&gt;65536 | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/sysctl.conf
&lt;span class="c"&gt;# Then reload the new configuration values&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it.&lt;/p&gt;

&lt;p&gt;If you just want to set it temporarily, just run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl fs.inotify.max_user_watches&lt;span class="o"&gt;=&lt;/span&gt;65536
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also put it in your &lt;code&gt;/etc/profile&lt;/code&gt; so it will run on every restart. But I feel &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; is the better way.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>programming</category>
      <category>tools</category>
    </item>
    <item>
      <title>Moore's Law and Programming languages</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Thu, 02 Aug 2018 10:13:13 +0000</pubDate>
      <link>https://dev.to/abhinav/moores-law-and-programming-languages-pee</link>
      <guid>https://dev.to/abhinav/moores-law-and-programming-languages-pee</guid>
      <description>&lt;p&gt;Since Moore's law is leveling off, now developers will have to level up their game  to extract more performance out of same chips. I predict less JS (or Electron) and Python/Ruby/node, and more Go, Rust, Scala (and maybe assembly on the side).&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
    </item>
    <item>
      <title>How do you think Guido stepping down as BDFL will affect Python?</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Sat, 14 Jul 2018 13:00:07 +0000</pubDate>
      <link>https://dev.to/abhinav/how-do-you-think-guido-stepping-down-as-bdfl-will-affect-python-4lod</link>
      <guid>https://dev.to/abhinav/how-do-you-think-guido-stepping-down-as-bdfl-will-affect-python-4lod</guid>
      <description>&lt;p&gt;Edit:&lt;br&gt;
I missed the earlier discussion from 2 days ago&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/ben" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1%2Ff451a206-11c8-4e3d-8936-143d0a7e65bb.png" alt="ben"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/ben/guido-van-rossum-steps-down-as-pythons-bdfl-thoughts-4nc3" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Guido van Rossum steps down as Python's BDFL, thoughts?&lt;/h2&gt;
      &lt;h3&gt;Ben Halpern ・ Jul 12 '18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#python&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#discuss&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>discuss</category>
      <category>python</category>
    </item>
    <item>
      <title>What are the most used commands in your shell history?</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Wed, 04 Jul 2018 18:55:46 +0000</pubDate>
      <link>https://dev.to/abhinav/which-is-the-most-used-command-in-your-shell-history-5ca1</link>
      <guid>https://dev.to/abhinav/which-is-the-most-used-command-in-your-shell-history-5ca1</guid>
      <description>&lt;p&gt;Recently I came across a &lt;a href="https://www.reddit.com/r/linux/comments/8vzr3y/whats_the_most_frequent_terminal_command_you_use/"&gt;thread&lt;/a&gt; on reddit which asked users the most used command in their shell history.&lt;/p&gt;

&lt;p&gt;My results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;     1  419  13.0489%    git
     2  265  8.25288%    &lt;span class="nb"&gt;cd
     &lt;/span&gt;3  239  7.44316%    &lt;span class="nb"&gt;sudo
     &lt;/span&gt;4  122  3.79944%    &lt;span class="nb"&gt;cat
     &lt;/span&gt;5  77   2.39801%    which
     6  76   2.36686%    dkr
     7  72   2.24229%    &lt;span class="nb"&gt;rm
     &lt;/span&gt;8  60   1.86858%    rg
     9  57   1.77515%    yarn
    10  57   1.77515%    nvim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Obviously &lt;code&gt;git&lt;/code&gt; is my most used command because I ran it on my work laptop. It should be a lot more but I have been using prezto's &lt;code&gt;git&lt;/code&gt; aliases lately. Other common commands are &lt;code&gt;dkr&lt;/code&gt; which is an alias for &lt;code&gt;sudo docker&lt;/code&gt; and &lt;code&gt;rg&lt;/code&gt;, the binary for &lt;a href="https://dev.to/abhinav/rest-in-peace-grep-19h9"&gt;ripgrep&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I wonder how is it for the dev.to community?&lt;/p&gt;

&lt;p&gt;Use this command from &lt;a href="http://linux.byexamples.com/archives/332/what-is-your-10-common-linux-commands/"&gt;linux.byexample.com&lt;/a&gt; to list your most used commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;history&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"./"&lt;/span&gt; | column &lt;span class="nt"&gt;-c3&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;nl&lt;/span&gt; |  &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I use zsh and it was not working for me because zsh's &lt;code&gt;history&lt;/code&gt; command just prints a few most recent commands only. I had to tweak it a bit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;history &lt;/span&gt;1 | &lt;span class="nb"&gt;cat&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"./"&lt;/span&gt; | column &lt;span class="nt"&gt;-c3&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;nl&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n10&lt;/span&gt;
&lt;span class="c"&gt;# or&lt;/span&gt;
&lt;span class="nb"&gt;fc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; 1 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"./"&lt;/span&gt; | column &lt;span class="nt"&gt;-c3&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-nr&lt;/span&gt; | &lt;span class="nb"&gt;nl&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>linux</category>
      <category>shell</category>
      <category>bash</category>
    </item>
    <item>
      <title>Rest in peace, grep!</title>
      <dc:creator>Abhinav Kumar</dc:creator>
      <pubDate>Wed, 16 May 2018 21:16:00 +0000</pubDate>
      <link>https://dev.to/abhinav/rest-in-peace-grep-19h9</link>
      <guid>https://dev.to/abhinav/rest-in-peace-grep-19h9</guid>
      <description>&lt;p&gt;I'm not saying that &lt;code&gt;grep&lt;/code&gt; is slow or flawed in any way but it can be definitely faster (and better). And GNU grep is not the only player out there.&lt;/p&gt;

&lt;p&gt;Let me introduce &lt;a href="https://github.com/BurntSushi/ripgrep"&gt;&lt;code&gt;ripgrep&lt;/code&gt;&lt;/a&gt;, a grep/ag/ack alternative written in Rust.&lt;/p&gt;

&lt;p&gt;So why should you use &lt;code&gt;ripgrep&lt;/code&gt;? Because it's fast. Very fast! It has saner defaults. And it's written in Rust. (Topic for another time:)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Also, I just learnt that ripgrep powers Visual Studio Code's search.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Benefits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Did I tell you that it's crazy fast?&lt;/li&gt;
&lt;li&gt;It searches recursively by default.&lt;/li&gt;
&lt;li&gt;It ignores hidden and binary files by default.&lt;/li&gt;
&lt;li&gt;It respects .gitignore. It will skip listed files and directories by default.&lt;/li&gt;
&lt;li&gt;You can restrict your search to specific filetypes.&lt;/li&gt;
&lt;li&gt;It prints pretty.&lt;/li&gt;
&lt;li&gt;It supports file encodings other than UTF-8.&lt;/li&gt;
&lt;li&gt;It's crazy fast.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Gotchas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Doesn't have multiline search.&lt;/li&gt;
&lt;li&gt;Since it uses threads heavily to do work, ripgrep's output is not deterministic. Tip: Pipe the output through &lt;code&gt;sort&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It's not a drop-in replacement for GNU grep or ag though. So don't replace them with rg in scripts without testing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;If you have Rust toolchain (1.20 or newer) installed, you can install it using cargo. Add &lt;code&gt;~/.cargo/bin&lt;/code&gt; to $PATH if you haven't yet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cargo &lt;span class="nb"&gt;install &lt;/span&gt;ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run bleeding-edge Arch, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fedora users can install it using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;ripgrep
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are worrying about having to type 3 more letters everytime you search and don't know what an alias is, don't worry. The binary is called just &lt;code&gt;rg&lt;/code&gt;. (:&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;If you know how to use &lt;code&gt;grep&lt;/code&gt;, you can use &lt;code&gt;ripgrep&lt;/code&gt;. I'll just outline basic usage here though. Read the instructions on its GitHub page if you want to know everything about it.&lt;/p&gt;

&lt;p&gt;To search any word recursively in a directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rg &amp;lt;keyword&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;ripgrep&lt;/code&gt;'s default behavior is to skip hidden and binary files apart from everything ignored by git. Use &lt;code&gt;-uuu&lt;/code&gt; to disable that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To search a keyword in only specific filetypes, pass the file extension to -t switch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rg &lt;span class="nt"&gt;-tjs&lt;/span&gt; foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To search a keyword in files matching the specified glob:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;rg foo &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="s1"&gt;'bar.*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic Benchmarks
&lt;/h2&gt;

&lt;p&gt;I ran simple benchmarks on my machine (Core i7 6500U, 8GB RAM, KDE neon 5.12.5 based on Ubuntu 16.04) using &lt;code&gt;/usr/bin/time&lt;/code&gt; binary and ripgrep seems to beat GNU grep everytime (by a huge margin!).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;/usr/bin/time rg &lt;span class="nt"&gt;-uu&lt;/span&gt; import &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="c"&gt;# ~24 seconds&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;/usr/bin/time &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; import &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="c"&gt;# ~3 min 27 seconds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind that these are not scientific benchmarks by any means. Go to ripgrep's &lt;a href="https://github.com/BurntSushi/ripgrep"&gt;GitHub page&lt;/a&gt; for more comprehensive numbers.&lt;/p&gt;




&lt;p&gt;This post was originally published on my &lt;a href="https://abhnv.com/blog/2018/05/16/rip-grep.html"&gt;website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>linux</category>
      <category>rust</category>
      <category>tools</category>
    </item>
  </channel>
</rss>
