<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Scripting on MangoDriod</title><link>https://md.eknath.dev/categories/scripting/</link><description>Recent content in Scripting on MangoDriod</description><generator>Hugo -- 0.141.0</generator><language>en-us</language><lastBuildDate>Thu, 17 Jul 2025 22:46:54 +0530</lastBuildDate><atom:link href="https://md.eknath.dev/categories/scripting/index.xml" rel="self" type="application/rss+xml"/><item><title>Mastering Grep: Your Guide to Efficient Text Searching</title><link>https://md.eknath.dev/posts/shell/grep-cmd-tool/</link><pubDate>Thu, 17 Jul 2025 22:46:54 +0530</pubDate><guid>https://md.eknath.dev/posts/shell/grep-cmd-tool/</guid><description>&lt;p>In the world of the command line, &lt;code>grep&lt;/code> is a tool you&amp;rsquo;ll find indispensable. It stands for &amp;ldquo;global regular expression print,&amp;rdquo; and it&amp;rsquo;s your go-to for searching text within files. Whether you&amp;rsquo;re a developer, a system administrator, or just someone who loves the terminal, mastering &lt;code>grep&lt;/code> will significantly boost your productivity. This article, inspired by the style of my &lt;a href="./basic-bash-commands.md">Basic Bash Commands&lt;/a> reference, will guide you through the essentials and advanced uses of &lt;code>grep&lt;/code>.&lt;/p></description><content:encoded><![CDATA[<p>In the world of the command line, <code>grep</code> is a tool you&rsquo;ll find indispensable. It stands for &ldquo;global regular expression print,&rdquo; and it&rsquo;s your go-to for searching text within files. Whether you&rsquo;re a developer, a system administrator, or just someone who loves the terminal, mastering <code>grep</code> will significantly boost your productivity. This article, inspired by the style of my <a href="./basic-bash-commands.md">Basic Bash Commands</a> reference, will guide you through the essentials and advanced uses of <code>grep</code>.</p>
<h2 id="what-is-grep">What is <code>grep</code>?</h2>
<p>At its core, <code>grep</code> is a command-line utility that searches for a specific pattern of text in a file or a stream of data. If it finds a match, it will print the line containing that pattern to the console. Its power lies in its simplicity and its support for regular expressions, which allows for incredibly flexible and powerful search queries.</p>
<h2 id="basic-syntax">Basic Syntax</h2>
<p>The basic syntax for <code>grep</code> is straightforward:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#f92672">[</span>options<span style="color:#f92672">]</span> pattern <span style="color:#f92672">[</span>file...<span style="color:#f92672">]</span>
</span></span></code></pre></div><ul>
<li><code>[options]</code>: These are flags that modify the behavior of <code>grep</code>.</li>
<li><code>pattern</code>: This is the text or regular expression you are searching for.</li>
<li><code>[file...]</code>: This is the file or files you want to search in. If no file is specified, <code>grep</code> will search the standard input.</li>
</ul>
<h2 id="daily-use-cases">Daily Use Cases</h2>
<p>Here are some of the most common ways you&rsquo;ll use <code>grep</code> in your day-to-day tasks:</p>
<h3 id="simple-text-search">Simple Text Search</h3>
<p>The most basic use of <code>grep</code> is to search for a specific word in a file.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;error&#34;</span> log.txt
</span></span></code></pre></div><p>This command will search for the word &ldquo;error&rdquo; in the <code>log.txt</code> file and print all lines that contain it.</p>
<h3 id="case-insensitive-search">Case-Insensitive Search</h3>
<p>If you want to ignore the case of the text you&rsquo;re searching for, use the <code>-i</code> option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep -i <span style="color:#e6db74">&#34;error&#34;</span> log.txt
</span></span></code></pre></div><p>This will find &ldquo;error&rdquo;, &ldquo;Error&rdquo;, &ldquo;ERROR&rdquo;, and so on.</p>
<h3 id="searching-in-multiple-files">Searching in Multiple Files</h3>
<p>You can search for a pattern in multiple files by listing them after the pattern.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;api_key&#34;</span> config.yml settings.py
</span></span></code></pre></div><h3 id="recursive-search">Recursive Search</h3>
<p>To search for a pattern in all files within a directory and its subdirectories, use the <code>-r</code> option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep -r <span style="color:#e6db74">&#34;database_url&#34;</span> .
</span></span></code></pre></div><p>This is incredibly useful for finding where a particular variable or function is used in a large project.</p>
<h2 id="medium-complexity-use-cases">Medium Complexity Use Cases</h2>
<p>Once you&rsquo;re comfortable with the basics, you can start using <code>grep</code> for more complex tasks.</p>
<h3 id="inverting-the-search">Inverting the Search</h3>
<p>If you want to find all the lines that <em>don&rsquo;t</em> contain a pattern, use the <code>-v</code> option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep -v <span style="color:#e6db74">&#34;success&#34;</span> log.txt
</span></span></code></pre></div><p>This is useful for filtering out noise from log files.</p>
<h3 id="counting-matches">Counting Matches</h3>
<p>To count the number of lines that match a pattern, use the <code>-c</code> option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep -c <span style="color:#e6db74">&#34;warning&#34;</span> log.txt
</span></span></code></pre></div><h3 id="showing-line-numbers">Showing Line Numbers</h3>
<p>To display the line number of each match, use the <code>-n</code> option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep -n <span style="color:#e6db74">&#34;TODO&#34;</span> *.py
</span></span></code></pre></div><p>This helps you quickly jump to the relevant line in your code editor.</p>
<h2 id="advanced-grep-with-regular-expressions">Advanced <code>grep</code> with Regular Expressions</h2>
<p>The true power of <code>grep</code> is unlocked when you use it with regular expressions. Here are a few examples:</p>
<h3 id="matching-the-start-and-end-of-a-line">Matching the Start and End of a Line</h3>
<p>You can use <code>^</code> to match the beginning of a line and <code>$</code> to match the end.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;^import&#34;</span> *.py  <span style="color:#75715e"># Find all lines that start with &#34;import&#34;</span>
</span></span><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;)</span>$<span style="color:#e6db74">&#34;</span> *.js      <span style="color:#75715e"># Find all lines that end with &#34;)&#34;</span>
</span></span></code></pre></div><h3 id="matching-any-character">Matching Any Character</h3>
<p>The <code>.</code> character in a regular expression matches any single character.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;gr.p&#34;</span> words.txt <span style="color:#75715e"># Matches &#34;grep&#34;, &#34;grip&#34;, &#34;grap&#34;, etc.</span>
</span></span></code></pre></div><h3 id="using-character-classes">Using Character Classes</h3>
<p>You can use character classes to match a set of characters.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;[aeiou]&#34;</span> text.txt <span style="color:#75715e"># Find all lines with at least one vowel</span>
</span></span></code></pre></div><h2 id="combining-grep-with-other-commands">Combining <code>grep</code> with Other Commands</h2>
<p><code>grep</code> is often used with other commands to create powerful command-line pipelines.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ps aux | grep <span style="color:#e6db74">&#34;nginx&#34;</span> <span style="color:#75715e"># Find all running processes with &#34;nginx&#34; in their name</span>
</span></span></code></pre></div><p>This command takes the output of <code>ps aux</code> and uses <code>grep</code> to filter it.</p>
<h2 id="conclusion">Conclusion</h2>
<p><code>grep</code> is a versatile and powerful tool that is essential for anyone who works with the command line. From simple text searches to complex pattern matching with regular expressions, <code>grep</code> can handle it all.</p>
<p>Thank you</p>
]]></content:encoded></item><item><title>Basic Bash Commands</title><link>https://md.eknath.dev/posts/shell/basic-bash-commands/</link><pubDate>Wed, 11 Jun 2025 20:46:54 +0530</pubDate><guid>https://md.eknath.dev/posts/shell/basic-bash-commands/</guid><description>&lt;p>One of my mentors, &lt;a href="https://linktr.ee/rwxrob">RWX-Rob&lt;/a>, runs online bootcamps called Boost, where he shares tech industry standards. A key lesson he emphasizes is the importance of learning Linux and working with its Bash command-line. Mastering the terminal has helped me save time and stay focused. These are my quick reference notes — not an exhaustive list, but the commands I use most often and im sure it will be useful for you too.&lt;/p></description><content:encoded><![CDATA[<p>One of my mentors, <a href="https://linktr.ee/rwxrob">RWX-Rob</a>, runs online bootcamps called Boost, where he shares tech industry standards. A key lesson he emphasizes is the importance of learning Linux and working with its Bash command-line. Mastering the terminal has helped me save time and stay focused. These are my quick reference notes — not an exhaustive list, but the commands I use most often and im sure it will be useful for you too.</p>
<p>btw BASH is short for Bourne Again SHell, just in case some one asks, so lets move it:</p>
<h2 id="mac-switching-between-zsh-and-bash">Mac Switching between Zsh and Bash</h2>
<p>As a software developer, choose <strong>Bash</strong> if you&rsquo;re new to shell scripting due to its familiarity and abundance of online resources, while opting for <strong>Zsh</strong> for improved performance, customization, and
security features, keeping in mind that switching to Zsh might require adapting to some differences when working with Linux distributions.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>chsh -s /bin/bash  <span style="color:#75715e"># switch to bash</span>
</span></span><span style="display:flex;"><span>chsh -s /bin/zsh   <span style="color:#75715e"># Switch to zsh</span>
</span></span></code></pre></div><h2 id="identity">Identity</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>pwd             <span style="color:#75715e"># Print current working directory</span>
</span></span><span style="display:flex;"><span>whoami          <span style="color:#75715e"># Show current user</span>
</span></span><span style="display:flex;"><span>clear           <span style="color:#75715e"># Clear the terminal screen</span>
</span></span><span style="display:flex;"><span>history         <span style="color:#75715e"># Show command history</span>
</span></span></code></pre></div><h2 id="file--directory-navigation">File &amp; Directory Navigation</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ls              <span style="color:#75715e"># List files</span>
</span></span><span style="display:flex;"><span>ls -la          <span style="color:#75715e"># List all files with details</span>
</span></span><span style="display:flex;"><span>cd /path/to/dir <span style="color:#75715e"># Change directory</span>
</span></span><span style="display:flex;"><span>cd ..           <span style="color:#75715e"># Go up one directory</span>
</span></span><span style="display:flex;"><span>cd -            <span style="color:#75715e"># Go to previous directory</span>
</span></span></code></pre></div><h2 id="file-operations">File Operations</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>touch file.txt              <span style="color:#75715e"># Create a new empty file</span>
</span></span><span style="display:flex;"><span>mkdir folder                <span style="color:#75715e"># Create a new directory</span>
</span></span><span style="display:flex;"><span>cp file1.txt file2.txt      <span style="color:#75715e"># Copy file or dir</span>
</span></span><span style="display:flex;"><span>mv file1.txt file2.txt      <span style="color:#75715e"># Rename or move file or dir</span>
</span></span><span style="display:flex;"><span>rm file.txt                 <span style="color:#75715e"># Delete file </span>
</span></span><span style="display:flex;"><span>rm -r folder                <span style="color:#75715e"># Delete directory recursively</span>
</span></span></code></pre></div><h2 id="searching--finding">Searching &amp; Finding</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;text&#34;</span> file.txt        <span style="color:#75715e"># Search for text in a file</span>
</span></span><span style="display:flex;"><span>grep -r <span style="color:#e6db74">&#34;text&#34;</span> .            <span style="color:#75715e"># Recursive search in directory</span>
</span></span><span style="display:flex;"><span>find . -name <span style="color:#e6db74">&#34;*.sh&#34;</span>         <span style="color:#75715e"># Find all .sh files</span>
</span></span></code></pre></div><h2 id="editing-files">Editing Files</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>vi file.txt                 <span style="color:#75715e"># Open file in Vim editor (i don&#39;t like nano sorry!) </span>
</span></span><span style="display:flex;"><span>cat file.txt                <span style="color:#75715e"># Print file content</span>
</span></span><span style="display:flex;"><span>less file.txt               <span style="color:#75715e"># Scroll through file</span>
</span></span><span style="display:flex;"><span>head file.txt               <span style="color:#75715e"># First 10 lines</span>
</span></span><span style="display:flex;"><span>tail file.txt               <span style="color:#75715e"># Last 10 lines</span>
</span></span></code></pre></div><ul>
<li>Vim Editor has its own commands and pallets, will add my reference here.</li>
</ul>
<h2 id="manual">Manual</h2>
<p>The <code>man</code> command provides access to the manual pages for other commands, offering detailed information on their usage and options.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>man ls <span style="color:#75715e"># show the manual for ls command</span>
</span></span></code></pre></div><h2 id="permissions">Permissions</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>chmod +x script.sh          <span style="color:#75715e"># Make script executable</span>
</span></span><span style="display:flex;"><span>chmod <span style="color:#ae81ff">755</span> file              <span style="color:#75715e"># Set permissions (owner rwx, others rx)</span>
</span></span><span style="display:flex;"><span>chown user:group file       <span style="color:#75715e"># Change ownership</span>
</span></span><span style="display:flex;"><span>ls -l file                  <span style="color:#75715e"># Get info of file permissions and owner etc</span>
</span></span><span style="display:flex;"><span>ls -ld folder               <span style="color:#75715e"># Get info of folder permissions and owner etc</span>
</span></span></code></pre></div><h3 id="permissions-string-quick-reference">Permissions String Quick Reference</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> user group <span style="color:#ae81ff">1234</span> Jun <span style="color:#ae81ff">16</span> 19:00 myfile.txt <span style="color:#75715e"># Example output for ls -l file check the table for ref</span>
</span></span><span style="display:flex;"><span>drwxr-xr-x <span style="color:#ae81ff">2</span> user group <span style="color:#ae81ff">4096</span> Jun <span style="color:#ae81ff">16</span> 19:00 mydir <span style="color:#75715e"># Example output for ls -ld folder check the table for ref</span>
</span></span></code></pre></div><table>
  <thead>
      <tr>
          <th>Position</th>
          <th>Meaning</th>
          <th>Example</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>1st char</td>
          <td>File type (<code>-</code> file, <code>d</code> directory, <code>l</code> symlink)</td>
          <td><code>-</code> = file, <code>d</code> = directory</td>
      </tr>
      <tr>
          <td>2-4</td>
          <td>Owner permissions (read <code>r</code>, write <code>w</code>, execute <code>x</code>)</td>
          <td><code>rwx</code> = owner can read, write, execute</td>
      </tr>
      <tr>
          <td>5-7</td>
          <td>Group permissions</td>
          <td><code>r-x</code> = group can read, execute</td>
      </tr>
      <tr>
          <td>8-10</td>
          <td>Others permissions</td>
          <td><code>r--</code> = others can only read</td>
      </tr>
  </tbody>
</table>
<h2 id="scripts--variables">Scripts &amp; Variables</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>echo <span style="color:#e6db74">&#34;Hello, </span>$USER<span style="color:#e6db74">&#34;</span>         <span style="color:#75715e"># Sample Bash script</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Variables</span>
</span></span><span style="display:flex;"><span>name<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;Eganathan&#34;</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;Hi, </span>$name<span style="color:#e6db74">&#34;</span>
</span></span></code></pre></div><h2 id="loops--conditions">Loops &amp; Conditions</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># If</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> -f <span style="color:#e6db74">&#34;file.txt&#34;</span> <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;Exists&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">fi</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For loop</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> f in *.txt; <span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;</span>$f<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">done</span>
</span></span></code></pre></div><h2 id="time-savers">Time Savers</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>!!              <span style="color:#75715e"># Repeat last command</span>
</span></span><span style="display:flex;"><span>!abc            <span style="color:#75715e"># Run last command starting with &#39;abc&#39;</span>
</span></span><span style="display:flex;"><span>Ctrl + R        <span style="color:#75715e"># Reverse search command history</span>
</span></span><span style="display:flex;"><span>Ctrl + L        <span style="color:#75715e"># Clear screen (same as `clear`)</span>
</span></span><span style="display:flex;"><span>Ctrl + A / E    <span style="color:#75715e"># Move to beginning / end of line</span>
</span></span></code></pre></div><h2 id="date-time">Date Time</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>date <span style="color:#75715e"># Print current date and time</span>
</span></span><span style="display:flex;"><span>date +<span style="color:#e6db74">&#34;%T&#34;</span>        <span style="color:#75715e"># Print current time in 24-hour format (HH:MM:SS)</span>
</span></span><span style="display:flex;"><span>date +<span style="color:#e6db74">&#34;%r&#34;</span>        <span style="color:#75715e"># Print current time in 12-hour format with AM/PM</span>
</span></span><span style="display:flex;"><span>date +<span style="color:#e6db74">&#34;%F&#34;</span>        <span style="color:#75715e"># Print current date in YYYY-MM-DD format</span>
</span></span><span style="display:flex;"><span>date +<span style="color:#e6db74">&#34;%d-%m-%Y&#34;</span>  <span style="color:#75715e"># Print current date in custom format: Day Month Year</span>
</span></span><span style="display:flex;"><span>date -u           <span style="color:#75715e"># Print current UTC time</span>
</span></span></code></pre></div><h2 id="use-alias-to-create-shortcuts">Use alias to create shortcuts</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>alias gs<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;git status&#34;</span> <span style="color:#75715e"># hope you have git installed</span>
</span></span><span style="display:flex;"><span>alias ..<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;cd ..&#34;</span> <span style="color:#75715e"># this have saved a quite a lot of time for me</span>
</span></span></code></pre></div><h2 id="combine-commands">Combine commands</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>command1 <span style="color:#f92672">&amp;&amp;</span> command2  <span style="color:#75715e"># Run command2 only if command1 succeeds</span>
</span></span><span style="display:flex;"><span>command1 <span style="color:#f92672">||</span> command2  <span style="color:#75715e"># Run command2 only if command1 fails</span>
</span></span></code></pre></div><h2 id="copy-file-contents">copy file contents</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat file.txt | pbcopy
</span></span></code></pre></div><h2 id="cleaning">Cleaning</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>df -h           <span style="color:#75715e"># Disk usage</span>
</span></span><span style="display:flex;"><span>du -sh *        <span style="color:#75715e"># Folder sizes</span>
</span></span><span style="display:flex;"><span>top             <span style="color:#75715e"># Real-time process list</span>
</span></span><span style="display:flex;"><span>ps aux | grep xyz  <span style="color:#75715e"># Check if a process is running</span>
</span></span></code></pre></div><h2 id="configuration-files">Configuration Files</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Bash</span>
</span></span><span style="display:flex;"><span>cat ~/.bash_profile   <span style="color:#75715e"># Main configuration file</span>
</span></span><span style="display:flex;"><span>cat ~/.bashrc         <span style="color:#75715e"># Profile configuration file</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Zsh (Mac)</span>
</span></span><span style="display:flex;"><span>cat ~/.zshrc          <span style="color:#75715e"># Main configuration file</span>
</span></span><span style="display:flex;"><span>cat ~/.zprofile       <span style="color:#75715e"># Profile configuration file</span>
</span></span></code></pre></div><p>These files persist aliases or environment variables and your personal scripts, this is really helpful to customize the shell for your taste</p>
<p>✅ Use the Main configuration file for environment variables like JAVA PATH and others.
✅ Use the Profile Configuration File for aliases and other similar settings.</p>
<p>⚠️ Once you add your alias or update the profile configuration, you will need to re-start the terminal for the new configuration to come into effect.</p>
<p>I keep a copy of the profile configuration in git so i have access to my configurations both on my work and other systems if i need em.</p>
<h2 id="common-commandline-tool-that-is-used-often-by-me">Common commandline tool that is used often by me</h2>
<ul>
<li>homebrew - package manager like npm</li>
<li>ddgr - search from the commandline (DuckDuckGo)</li>
<li>ollama - for local offline AI models for simple tasks and quires.</li>
<li>zip/unzip – Compress/uncompress</li>
<li>curl - API testing and others</li>
</ul>
<blockquote>
<p>&ldquo;Warning: Terminal use may cause excessive productivity and happiness.&rdquo; - Ollama 3.5</p>
</blockquote>
]]></content:encoded></item></channel></rss>