<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Scripting on Amit Agarwal Linux Blog</title>
    <link>/tags/scripting/</link>
    <description>Recent content in Scripting on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 17 Oct 2025 00:00:00 +0530</lastBuildDate>
    
	<atom:link href="/tags/scripting/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Color-Coded URL Status Checker in Bash: Enhanced Script for Fast Web Health Monitoring</title>
      <link>/2025/10/17/2025-10-17-Check_urls/</link>
      <pubDate>Fri, 17 Oct 2025 00:00:00 +0530</pubDate>
      
      <guid>/2025/10/17/2025-10-17-Check_urls/</guid>
      <description>Upgrade your Bash scripting game with a color-coded URL status checker that leverages curl, timeout handling, and clean output for fast web monitoring.</description>
    </item>
    
    <item>
      <title>Hackernews In Your Inbox</title>
      <link>/2024/08/25/2024-08-25-HackernewsInYourInbox/</link>
      <pubDate>Sun, 25 Aug 2024 00:00:00 +0530</pubDate>
      
      <guid>/2024/08/25/2024-08-25-HackernewsInYourInbox/</guid>
      <description>&lt;p&gt;If you do not want to subscribe to any newsletter but still want to get some news delivered to you inbox then this post is for you.&lt;/p&gt;
&lt;p&gt;First you need to get a script that can pull the hacker-news articles for you and you can find my script &lt;a href=&#34;https://github.com/raj77in/pentools/blob/main/misc/hacker-news.py&#34;&gt;here&lt;/a&gt;. You can modify this script, specially the line: &lt;code&gt;for id in trending_list[:50]:&lt;/code&gt; to change the number of posts that you would like to see in the mail.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Warn when battery is low</title>
      <link>/2020/08/30/acpi-warn/</link>
      <pubDate>Sun, 30 Aug 2020 00:05:57 +0530</pubDate>
      
      <guid>/2020/08/30/acpi-warn/</guid>
      <description>&lt;p&gt;I am very lazy to look at battery status and want to be warned when the battery
is low. This means that even if I am away from the laptop, I can be warned that
laptop is about to poweroff due to battery low. So, what kind of alerts I can have, many -&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;zenity message box&lt;/li&gt;
&lt;li&gt;email&lt;/li&gt;
&lt;li&gt;sms with twillio&lt;/li&gt;
&lt;li&gt;Telegram message
and possibility is endless.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;LOW&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;35&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;## This si the lowest percentage at which I want the alerts.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;## Parse the acpi statue and decide if alert needs to be sent&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;per&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=$&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;usr&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;acpi&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;b&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;awk&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;{print $4}&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sed&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;s/%.*//&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# source ~/bin/cron-scripts/sendsms.sh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[[&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;usr&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;acpi&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;grep&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Full\|Charging&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;]]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;#This is when the AC is connected.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;exit&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[[&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;z&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;per&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;per&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;$&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LOW&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;]]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# sendsms &amp;#34;Battery is at $per%&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sub&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Battery is at $per%&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Battery is running out : $per&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;usr&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sbin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sendmail&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;display_msg&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sh&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;ACPI Warn&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Battery is at $per%&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;ACPI Warn&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Battery is at $per%&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;home&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;amitag&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;twilio&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sms&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;919535210501&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;zenity&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;--&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;warning&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;--&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;text&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Battery is at $per%&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Put this script somewhere and schedule in cron for every minute and enjoy.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Some good find alias.</title>
      <link>/2020/08/16/find-alias/</link>
      <pubDate>Sun, 23 Aug 2020 11:05:57 +0530</pubDate>
      
      <guid>/2020/08/16/find-alias/</guid>
      <description>&lt;p&gt;Here are some interesting alias&amp;rsquo;s that you may want to add to your
bashrc file or where-ever else you add your aliase&amp;rsquo;s. Very useful if you
use find commonly.&lt;/p&gt;
&lt;p&gt;There are four aliases defined here and have a comment explaining what
it does. but these are so simple and useful that you probably dont even
need the comments.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# ff:  to find a file under the current directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ff &lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; find . -name &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$@&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# ffs: to find a file whose name starts with a given string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ffs &lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; find . -name &lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$@&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;*&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# ffe: to find a file whose name ends with a given string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ffe &lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; find . -name &lt;span class=&#34;s1&#34;&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$@&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# very very useful function: for finding files with ignore case, just type &amp;#34;f &amp;lt;part of filename&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# This in combination with alias for &amp;#39;g&amp;#39; is deadly.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;f &lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; find . -iname &lt;span class=&#34;s1&#34;&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;$@&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;*&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Hope this is useful for you.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Books menu with bash</title>
      <link>/2020/08/16/books-menu-with-bash/</link>
      <pubDate>Sun, 16 Aug 2020 11:05:57 +0530</pubDate>
      
      <guid>/2020/08/16/books-menu-with-bash/</guid>
      <description>&lt;p&gt;If you have a folder full of ebooks in various formats and not necessarily
one sigle format and you want to have a quick menu to browse though your collection
without requiring to open a File Manager then you are going to love this script.&lt;/p&gt;
&lt;p&gt;The scripts works by allowing you to browse to the requied folder of your choice
and once you select the file, then using &lt;code&gt;xdg-open&lt;/code&gt; to open the file with your default
viewer.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Pygmentize Styles</title>
      <link>/2020/07/26/pygmentize-styles/</link>
      <pubDate>Sun, 26 Jul 2020 18:38:57 +0530</pubDate>
      
      <guid>/2020/07/26/pygmentize-styles/</guid>
      <description>&lt;p&gt;I have recently started using pygmentize for looking at my code in terminal.
A very good and native way to do this is to use pygmentize. If you do not know
about pygmentize then&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Highlight the input file and write the result to &lt;outfile&gt;.
If no input file is given, use stdin, if -o is not given, use stdout.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, you can simply pass the script or source code through pygmentize and
get a lovely color output with code highlighting in the terminal and this
can be very useful.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>scripting – performance improvement with file open</title>
      <link>/2020/04/20/scripting-performance-improvement-file-open/</link>
      <pubDate>Mon, 20 Apr 2020 01:01:37 +0000</pubDate>
      
      <guid>/2020/04/20/scripting-performance-improvement-file-open/</guid>
      <description>&lt;p&gt;Sometimes just one line of code can make all the difference. I will show you with example.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here is script with 2 functions. Both are writing some lines of text to a file. First function, “a” I have used the redirection to write to file. Function “b”, I have opened a file descriptor with “&amp;gt;” before going into the loop and use that reference for writing to the file. (This concept remains same for any scripting or programming language).&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>i3 – show mapped hotkeys</title>
      <link>/2019/12/02/i3-show-mapped-hotkeys/</link>
      <pubDate>Mon, 02 Dec 2019 01:05:19 +0000</pubDate>
      
      <guid>/2019/12/02/i3-show-mapped-hotkeys/</guid>
      <description>&lt;p&gt;Here is a simple script that can show you the hotkeys bound in ~/.config/i3/config :&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;#!/bin/bash - 
#===============================================================================
#
#          FILE: i3-showkeys.sh
# 
#         USAGE: ./i3-showkeys.sh 
# 
#   DESCRIPTION: 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#  ORGANIZATION: Individual
#       CREATED: 11/26/2019 14:22
# Last modified: Tue Nov 26, 2019  02:43PM
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error


&gt; /tmp/keys
cd ~/.config/i3
grep &#39;^bindsym $mod&#39; config|grep -v &#39;^#&#39;|grep -v &#39;move container to&#39;|grep -v &#39;workspace $ws&#39;|sed &#39;s/bindsym //&#39;|grep -v &#39;=&#39;|while read key line
do
    printf &#34;%20s\t?\t%s\n&#34; &#34;$key&#34; &#34;$line&#34;  &amp;gt;&amp;gt; /tmp/keys
done

xterm -e &#34;cat /tmp/keys; read -p &#39;press any key to continue&#39;&#34;
rm -f /tmp/keys
&lt;/pre&gt;
&lt;p&gt;And once this is done, you can bind the script in i3 config like this:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>scan your network with bash IP scan script</title>
      <link>/2019/10/10/scan-your-network-with-bash-ip-scan-script/</link>
      <pubDate>Thu, 10 Oct 2019 07:05:41 +0000</pubDate>
      
      <guid>/2019/10/10/scan-your-network-with-bash-ip-scan-script/</guid>
      <description>&lt;p&gt;Here is the youtbe video that will walk you through bash script.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;embed-youtube&#34; style=&#34;text-align:center; display: block;&#34;&gt;&lt;/span&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>cool sed/grep magic to convert output to csv format</title>
      <link>/2019/03/11/cool-sed-grep-magic-to-convert-output-to-csv-format/</link>
      <pubDate>Mon, 11 Mar 2019 01:12:34 +0000</pubDate>
      
      <guid>/2019/03/11/cool-sed-grep-magic-to-convert-output-to-csv-format/</guid>
      <description>&lt;p&gt;I generallly keep doing this a lot, so thought will share with you. Lets assume we are capturing free ouput every min/hour/or whatever. The output looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Time: Mon Jan 21 23:59:10 AEDT 2019&lt;br&gt;
——————-&lt;/p&gt;
&lt;p&gt;total        used        free      shared  buff/cache   available&lt;br&gt;
Mem:          32014        8656        1735        1697       21621       21308&lt;br&gt;
Swap: 51195 75 51120&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;then we can use some grep and sed to convert this to something like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Mon Jan 21 23:59:10 AEDT 2019,32014,8656,1735,1697,21621,21308&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Get to your ebooks quickly</title>
      <link>/2018/11/12/get-to-your-ebooks-quickly/</link>
      <pubDate>Mon, 12 Nov 2018 01:05:03 +0000</pubDate>
      
      <guid>/2018/11/12/get-to-your-ebooks-quickly/</guid>
      <description>&lt;div style=&#34;caret-color: #000000; color: #000000; font-family: Cantarell; font-size: 10.666666984558105px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;&#34;&gt;
  So this is going to be a little longer post than usual.&lt;br /&gt;&lt;br /&gt;To begin with, here is screenshot of how it would look like finally:
&lt;/div&gt;&lt;figure class=&#34;wp-block-image&#34;&gt;
&lt;p&gt;&lt;img class=&#34;wp-image-14250&#34; src=&#34;https://i1.wp.com/blog.amit-agarwal.co.in/wp-content/uploads/2018/11/books.png?w=688&#34; alt=&#34;&#34; srcset=&#34;https://i1.wp.com/blog.amit-agarwal.co.in/wp-content/uploads/2018/11/books.png?w=988 988w, https://i1.wp.com/blog.amit-agarwal.co.in/wp-content/uploads/2018/11/books.png?resize=300%2C67 300w, https://i1.wp.com/blog.amit-agarwal.co.in/wp-content/uploads/2018/11/books.png?resize=768%2C173 768w&#34; sizes=&#34;(max-width: 688px) 100vw, 688px&#34; data-recalc-dims=&#34;1&#34; /&gt; &lt;/figure&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Generate random string for various use case</title>
      <link>/2016/08/08/generate-random-string-case/</link>
      <pubDate>Mon, 08 Aug 2016 01:16:14 +0000</pubDate>
      
      <guid>/2016/08/08/generate-random-string-case/</guid>
      <description>&lt;p&gt;Some times I need random string, for example to use as email seperator or to use in some &lt;a class=&#34;zem_slink&#34; title=&#34;Application programming interface&#34; href=&#34;http://en.wikipedia.org/wiki/Application_programming_interface&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;API&lt;/a&gt;. One way is to use tools like &lt;a class=&#34;zem_slink&#34; title=&#34;Device file&#34; href=&#34;http://en.wikipedia.org/wiki/Device_file&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;/dev&lt;/a&gt;/[u]random or od and other such. But they seem cubersome after I figured this out.&lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;openssl rand &amp;lt;length&amp;gt;
openssl rand 10
&lt;/pre&gt;
&lt;p&gt;This alone without some parameters is not interesting thoug. You can use ‘-base64’ or ‘-hex’ to select the encoding.&lt;/p&gt;
&lt;p&gt;So if you execute the above you will get something like this&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>image ordering by Original Date Time using bash script</title>
      <link>/2016/01/05/image-ordering-original-date-time-bash-script/</link>
      <pubDate>Tue, 05 Jan 2016 00:55:10 +0000</pubDate>
      
      <guid>/2016/01/05/image-ordering-original-date-time-bash-script/</guid>
      <description>&lt;p&gt;Here is the script:&lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;#!/bin/bash -
#===============================================================================
#
#          FILE: imgOrg.sh
#
#         USAGE: ./imgOrg.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#      REVISION:  ---
#===============================================================================

for i in *
do
    if [[ $(file $i) == *image* ]] 
    then
        echo &#34;Image file is :: $i&#34;
        dir=$( exiftool -s -DateTimeOriginal $i | awk -F&#39;:&#39; &#39;{print $2&#34;/&#34;$3}&#39;)
        mkdir -p $dir
        cp $i $dir/
    else
        echo &#34;Excluding $i&#34;
    fi
done
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Get count of lines in scripts (shell)</title>
      <link>/2015/10/15/count-lines-scripts-shell/</link>
      <pubDate>Thu, 15 Oct 2015 00:41:52 +0000</pubDate>
      
      <guid>/2015/10/15/count-lines-scripts-shell/</guid>
      <description>&lt;p&gt;If you have tried to get the count of lines in file, the you would know about “nl” or “wc -l”. But as you are aware these give you number of lines with other details as well and you need to post process the number to make sure that you have only number and nothing else. In such cases, it is useful to use the count feature of grep and here is a shorthand to get the count of lines in any shell script:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Filename handling with space and newline character.</title>
      <link>/2010/05/25/filename-handling-with-space-and-newline-character/</link>
      <pubDate>Tue, 25 May 2010 11:34:01 +0000</pubDate>
      
      <guid>/2010/05/25/filename-handling-with-space-and-newline-character/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;http://www.andreaplanet.com/andreamosaic/download/&amp;quot;&amp;gt;&lt;/a&gt;&lt;br&gt;
&amp;lt;a href=&amp;quot;http://calypso.tux.org/pipermail/novalug/2009-February/017524.html&amp;quot;&amp;gt;[Novalug] Filename handling: correctness vs. convenience&lt;/a&gt; has a nice post from Michael Henry on Filename handling.&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class=\&#34;zemanta-pixie\&#34;&gt;&lt;img class=\&#34;zemanta-pixie-img\&#34; src=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/pixy2.gif\&#34; /&gt;&lt;/div&gt;&lt;/blockquote&gt;</description>
    </item>
    
    <item>
      <title>The power of find command in Linux – advanced.</title>
      <link>/2010/05/24/the-power-of-find-command-in-linux-advanced/</link>
      <pubDate>Mon, 24 May 2010 16:25:40 +0000</pubDate>
      
      <guid>/2010/05/24/the-power-of-find-command-in-linux-advanced/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Generally whoever uses Linux, would know about the find command. Find the man page &amp;lt;a href=&amp;quot;http://amit.themafia.info/phpMan.php?parameter=find&amp;amp;mode=man&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are also lots of blogs, tutorials and other articles on find command on the web, so why write another one. Because it&amp;amp;#8217;s worth every word spent on it 🙂&lt;br&gt;
find is a very powerful command, let&amp;amp;#8217;s see how (options for find command from man page and usage):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;–&lt;strong&gt;depth&lt;/strong&gt; — Process each directory&amp;amp;#8217;s contents before the directory itself.&lt;br&gt;
–&lt;strong&gt;maxdepth&lt;/strong&gt; — Descend at most &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;levels&lt;/span&gt; (a non-negative integer) levels of directories below the command line arguments.&lt;br&gt;
–&lt;strong&gt;xdev&lt;/strong&gt; — Don&amp;amp;#8217;t descend directories on other filesystems.&lt;br&gt;
–&lt;strong&gt;executable&lt;/strong&gt; — Matches files which are executable and directories which are searchable (in a file name resolution sense).&lt;br&gt;
This takes into account access control lists and other permissions artefacts which the &lt;strong&gt;-perm&lt;/strong&gt; test ignores.&lt;br&gt;
–&lt;strong&gt;iname&lt;/strong&gt; — Like &lt;strong&gt;-name&lt;/strong&gt;, but the match is case insensitive.&lt;br&gt;
–&lt;strong&gt;nogroup&lt;/strong&gt; — No group corresponds to file&amp;amp;#8217;s numeric group ID.&lt;br&gt;
–&lt;strong&gt;nouser&lt;/strong&gt; — No user corresponds to file&amp;amp;#8217;s numeric user ID.&lt;br&gt;
–&lt;strong&gt;fls&lt;/strong&gt; &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;file&lt;/span&gt; — True; like &lt;strong&gt;-ls&lt;/strong&gt; but write to &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;file&lt;/span&gt; like &lt;strong&gt;-fprint&lt;/strong&gt;.&lt;br&gt;
–&lt;strong&gt;ok&lt;/strong&gt; &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;command&lt;/span&gt; — Like &lt;strong&gt;-exec&lt;/strong&gt; but ask the user first (on the standard input);&lt;br&gt;
–&lt;strong&gt;print0&lt;/strong&gt; — True; print the full file name on the standard output, followed by a null character&lt;br&gt;
(instead of the newline character that &lt;strong&gt;-print&lt;/strong&gt; uses).&lt;br&gt;
–&lt;strong&gt;printf&lt;/strong&gt; &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;format&lt;/span&gt; — True; print &amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;format&lt;/span&gt; on the standard output, interpreting &amp;amp;#8217;&amp;amp;#8217; escapes and &amp;amp;#8217;%&amp;amp;#8217; directives.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>parse and paste text</title>
      <link>/2020/06/08/parse-paste-text/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/2020/06/08/parse-paste-text/</guid>
      <description>&lt;p&gt;Lot of times, I copy the text but before pasting want to remove a word or make some other changes or add “wget” to the URL, quite common. So, I came up with this alias&lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;replace=&#39;echo $(xclip -i)|sed &#39;s/text//&#39;|xclip -o&#39;&lt;/pre&gt;
&lt;p&gt;and this depends on xlip, which you can install with&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;dnf install xclip&lt;/pre&gt;</description>
    </item>
    
  </channel>
</rss>
