<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Grep on Amit Agarwal Linux Blog</title>
    <link>/tags/grep/</link>
    <description>Recent content in Grep on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 02 Apr 2022 00:00:00 +0530</lastBuildDate>
    
	<atom:link href="/tags/grep/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Creating and using ackrc</title>
      <link>/2022/04/02/Creating-and-using-ackrc/</link>
      <pubDate>Sat, 02 Apr 2022 00:00:00 +0530</pubDate>
      
      <guid>/2022/04/02/Creating-and-using-ackrc/</guid>
      <description>&lt;p&gt;&lt;strong&gt;ack&lt;/strong&gt; is a fantastic replacement for grep and probably much more than grep. Here is what the dnf info has to say about ack&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;/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-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name         : ack
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Architecture : noarch
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Summary      : Grep-like text finder
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;URL          : http://beyondgrep.com/
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;License      : Artistic 2.0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Description  : Ack is designed as a replacement for grep.
&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;And their websites says -&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Designed for programmers with large heterogeneous trees of source code, ack is written in portable Perl 5 and takes advantage of the power of Perl&amp;rsquo;s regular expressions.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>using cat with grep – why?</title>
      <link>/2020/01/06/cat-grep-why/</link>
      <pubDate>Mon, 06 Jan 2020 01:01:27 +0000</pubDate>
      
      <guid>/2020/01/06/cat-grep-why/</guid>
      <description>&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>GREP_COLORS – change the colors in the GREP output.</title>
      <link>/2019/04/22/grep_colors-change-the-colors-in-the-grep-output/</link>
      <pubDate>Mon, 22 Apr 2019 01:00:59 +0000</pubDate>
      
      <guid>/2019/04/22/grep_colors-change-the-colors-in-the-grep-output/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Today we will look at the variable &lt;strong&gt;GREP_COLORS&lt;/strong&gt;. This variable determines the &lt;a class=&#34;zem_slink&#34; title=&#34;Color&#34; href=&#34;http://en.wikipedia.org/wiki/Color&#34; rel=&#34;wikipedia&#34;&gt;colour&lt;/a&gt; that is used with the &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt; command. You can look at the &lt;a class=&#34;zem_slink&#34; title=&#34;Man page&#34; href=&#34;http://en.wikipedia.org/wiki/Man_page&#34; rel=&#34;wikipedia&#34;&gt;man page&lt;/a&gt; of the grep command to see what the various options mean. Here is the excerpt from the man command:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;GREP_COLORS
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code&gt;          Specifies the colors and other attributes used to highlight various  parts  of  the
          output.   Its  value  is  a  colon-separated  list of capabilities that defaults to
          ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36  with  the  rv  and  ne   boolean
          capabilities omitted (i.e., false).  Supported capabilities are as follows.

          sl=    SGR  &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Substring&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Substring&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;substring&amp;lt;/a&amp;gt;  for  whole  selected lines (i.e., matching lines when the -v
                 command-line option is omitted, or non-matching lines when -v is specified).
                 If however the boolean rv capability and the -v command-line option are both
                 specified, it applies to context matching lines  instead.   The  &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Default (finance)&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Default_%28finance%29&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;default&amp;lt;/a&amp;gt;  is
                 empty (i.e., the terminal&#39;s default color pair).

          cx=    SGR  substring for whole context lines (i.e., non-matching lines when the -v
                 command-line option is omitted, or matching lines when -v is specified).  If
                 however  the  boolean  rv capability and the -v command-line option are both
                 specified, it applies to selected non-matching lines instead.   The  default
                 is empty (i.e., the terminal&#39;s default color pair).

          rv     &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Boolean data type&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Boolean_data_type&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;Boolean  value&amp;lt;/a&amp;gt;  that  reverses  (swaps)  the  meanings  of  the  sl= and cx=
                 capabilities when the -v command-line option is specified.  The  default  is
                 false (i.e., the capability is omitted).

          mt=01;31
                 SGR  substring  for  matching  &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Empty set&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Empty_set&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;non-empty&amp;lt;/a&amp;gt;  text in any matching line (i.e., a
                 selected line when the -v command-line option is omitted, or a context  line
                 when  -v  is specified).  Setting this is equivalent to setting both ms= and
                 mc= at once to the same value.  The default is a bold  red  text  foreground
                 over the current line background.

          ms=01;31
                 SGR substring for matching non-empty text in a selected line.  (This is only
                 used when the -v command-line option is omitted.)  The effect of the sl= (or
                 cx=  if  rv) capability remains active when this kicks in.  The default is a
                 bold red text foreground over the current line background.

          mc=01;31
                 SGR substring for matching non-empty text in a context line.  (This is  only
                 used  when  the -v command-line option is specified.)  The effect of the cx=
                 (or sl= if rv) capability remains active when this kicks in.  The default is
                 a bold red text foreground over the current line background.

          fn=35  SGR  substring  for file names prefixing any content line.  The default is a
                 magenta text foreground over the terminal&#39;s default background.

          ln=32  SGR substring for &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Line number&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Line_number&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;line numbers&amp;lt;/a&amp;gt; prefixing any content line.  The default is a
                 green text foreground over the terminal&#39;s default background.

          bn=32  SGR substring for byte offsets prefixing any content line.  The default is a
                 green text foreground over the terminal&#39;s default background.

          se=36  SGR substring for separators that are inserted between selected line  fields
                 (:),  between context line fields, (-), and between groups of adjacent lines
                 when nonzero context  is  specified  (--).   The  default  is  a  cyan  text
                 foreground over the terminal&#39;s default background.

          ne     Boolean  value that prevents clearing to the &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Newline&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Newline&amp;quot; rel=&amp;quot;wikipedia&amp;quot;&amp;gt;end of line&amp;lt;/a&amp;gt; using Erase in Line
                 (EL) to Right (\33[K) each time a colorized item ends.  This  is  needed  on
                 terminals on which EL is not supported.  It is otherwise useful on terminals
                 for which the back_color_erase (bce) boolean terminfo  capability  does  not
                 apply,  when  the  chosen  highlight colors do not affect the background, or
                 when EL is too slow or causes too much flicker.  The default is false (i.e.,
                 the capability is omitted).
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/pre&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>nice little bash function to search for running processes</title>
      <link>/2014/10/13/nice-bash-function-search-running-processes/</link>
      <pubDate>Mon, 13 Oct 2014 00:20:31 +0000</pubDate>
      
      <guid>/2014/10/13/nice-bash-function-search-running-processes/</guid>
      <description>&lt;p&gt;Here is a nice little handy function that I use very regurlarly.&lt;/p&gt;
&lt;p&gt;You can use this function with parameter to just grep for that or just type psa to see all the running processes.&lt;/p&gt;
&lt;p&gt;Just put this in your &lt;strong&gt;.bashrc&lt;/strong&gt; file.&lt;/p&gt;
&lt;p&gt;You might find it useful:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;psa () 
{ 
    if [[ $1 == &#34;&#34; ]]; then
        ps -eaf;
    else
        ps -eaf | grep --color=auto -i $1;
    fi
}
&lt;/pre&gt;</description>
    </item>
    
    <item>
      <title>Raspberry Pi automate certain tasks  – script example</title>
      <link>/2014/03/10/raspberry-pi-automate-tasks-script/</link>
      <pubDate>Mon, 10 Mar 2014 01:41:45 +0000</pubDate>
      
      <guid>/2014/03/10/raspberry-pi-automate-tasks-script/</guid>
      <description>&lt;p&gt;Now, if you have followed these :&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://blog.amit-agarwal.co.in/2013/06/07/fetchmail-mails-imap-account/&#34; title=&#34;fetchmail&#34;&gt;fetchmail&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://blog.amit-agarwal.co.in/2013/06/04/ssmtp-configuration-installation-raspberry-pi&#34; title=&#34;ssmtp&#34;&gt;ssmtp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then you already have a working system for sending and receiving mail. Now, you can set the mda in the fetmailrc to a script which can do few things for you. The script below will get a page and mail it to you, if you have the subject as “get” and send “&lt;a class=&#34;zem_slink&#34; title=&#34;Wake-on-LAN&#34; href=&#34;http://en.wikipedia.org/wiki/Wake-on-LAN&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;wake on LAN&lt;/a&gt;” to desired PC if you have subject as “wol”. Cool 🙂&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Apache server stats with small and useful bash script.</title>
      <link>/2013/11/29/apache-server-stats-small-bash-script/</link>
      <pubDate>Fri, 29 Nov 2013 01:35:36 +0000</pubDate>
      
      <guid>/2013/11/29/apache-server-stats-small-bash-script/</guid>
      <description>&lt;p&gt;Just copy this script to your web-server &lt;a class=&#34;zem_slink&#34; title=&#34;Common Gateway Interface&#34; href=&#34;http://en.wikipedia.org/wiki/Common_Gateway_Interface&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;cgi-bin&lt;/a&gt; directory and enjoy.&lt;/p&gt;
&lt;p&gt;The script with show the common errors like &lt;a class=&#34;zem_slink&#34; title=&#34;HTTP 404&#34; href=&#34;http://en.wikipedia.org/wiki/HTTP_404&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;404 Error&lt;/a&gt;, &lt;a class=&#34;zem_slink&#34; title=&#34;List of HTTP status codes&#34; href=&#34;http://www.iana.org/assignments/http-status-codes&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;Internal Server Error&lt;/a&gt; and others. It will show the &lt;a class=&#34;zem_slink&#34; title=&#34;User agent&#34; href=&#34;http://en.wikipedia.org/wiki/User_agent&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;User agent&lt;/a&gt; distribution using simple commands like &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt;, &lt;a class=&#34;zem_slink&#34; title=&#34;Uniq&#34; href=&#34;http://en.wikipedia.org/wiki/Uniq&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;uniq&lt;/a&gt;, &lt;a class=&#34;zem_slink&#34; title=&#34;AWK&#34; href=&#34;http://cm.bell-labs.com/cm/cs/awkbook&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;awk&lt;/a&gt; and so on.&lt;/p&gt;
&lt;p&gt;You would need to change the tfile – which is temporary file and also the access.log path in the next line.&lt;/p&gt;
&lt;p&gt;Just re-direct the output to some file with html extenstion. You could even put this in the cron which re-directs the output to some html in server document root.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>bash – using the vi mode more effectively.</title>
      <link>/2013/11/22/bash-vi-mode-effectively/</link>
      <pubDate>Fri, 22 Nov 2013 01:50:24 +0000</pubDate>
      
      <guid>/2013/11/22/bash-vi-mode-effectively/</guid>
      <description>&lt;figure style=&#34;width: 240px&#34; class=&#34;wp-caption alignright&#34;&gt;&lt;a href=&#34;http://www.flickr.com/photos/36867590@N00/397369388&#34; target=&#34;_blank&#34;&gt;&lt;img class=&#34;zemanta-img-inserted zemanta-img-configured&#34; title=&#34;Vi blogging bundle&#34; alt=&#34;Vi blogging bundle&#34; src=&#34;https://i1.wp.com/farm1.static.flickr.com/160/397369388_6935e4572a_m.jpg?resize=240%2C180&#34; width=&#34;240&#34; height=&#34;180&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;&lt;figcaption class=&#34;wp-caption-text&#34;&gt;Vi blogging bundle (Photo credit: pedro mg)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;You can first set the &lt;a class=&#34;zem_slink&#34; title=&#34;Bash (Unix shell)&#34; href=&#34;http://www.gnu.org/software/bash/&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;bash&lt;/a&gt; mode to &lt;a class=&#34;zem_slink&#34; title=&#34;Vi&#34; href=&#34;http://en.wikipedia.org/wiki/Vi&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;vi&lt;/a&gt;. This will enable some vim like features to bash. So, add this to .bashrc :&lt;/p&gt;
&lt;pre class=&#34;brush: actionscript3; gutter: true; first-line: 1&#34;&gt;set -o vi&lt;/pre&gt;
&lt;p&gt;Once, you have done that then its time to get more out of the vi mode. First, check some things and set some interesting stuff.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Check all vim colorschemes for minor issues</title>
      <link>/2013/10/10/check-vim-colorschemes-minor-issues/</link>
      <pubDate>Thu, 10 Oct 2013 01:13:25 +0000</pubDate>
      
      <guid>/2013/10/10/check-vim-colorschemes-minor-issues/</guid>
      <description>&lt;p&gt;Here is script that checks all the colorschemes in the &lt;a class=&#34;zem_slink&#34; title=&#34;Working directory&#34; href=&#34;http://en.wikipedia.org/wiki/Working_directory&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;current directory&lt;/a&gt; and corrects them if possible (&lt;a class=&#34;zem_slink&#34; title=&#34;Processing (programming language)&#34; href=&#34;http://www.processing.org&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;Processing&lt;/a&gt; of the file is done with simple commands like &lt;a class=&#34;zem_slink&#34; title=&#34;Sed&#34; href=&#34;http://en.wikipedia.org/wiki/Sed&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;sed&lt;/a&gt;, &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Checks that the color_name is same as &lt;a class=&#34;zem_slink&#34; title=&#34;Filename&#34; href=&#34;http://en.wikipedia.org/wiki/Filename&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;Filename&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the script:&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;#!/bin/bash -
#===============================================================================
#
#          FILE: check_colors.sh
#
#         USAGE: ./check_colors.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka), 
#      REVISION:  ---
#===============================================================================
cd ~/.vim/colors
for i in *vim
do
    #echo &#34;Processing $i&#34;
    if [[ $(grep -c g:colors_name $i ) -eq 0 ]]; then
        if [[ $(grep -c colors_name $i ) -eq 0 ]]; then
            echo &#34;File $i does not have colorname&#34;;
            missing=$missing&#34; $i&#34;
        else
            sed -i.bak &#39;/colors_name/ s/.*/let g:colors_name=&#34;&#39;${i//.vim}&#39;&#34;/g&#39; $i
        fi
    else
        if [[ $(grep -c colors_name $i|grep let ) -gt 1 ]]; then
            echo &#34;WARN -----&amp;gt;&amp;gt; File $i has more than one colorsname&#34;
        fi
        colorname=$(grep g:colors_name $i|grep let| sed -e &#39;s/&#34;//g&#39; -e &#39;s/.*=//&#39; |tr -d &#39; &#39;)
        if [[ ${colorname}.vim != $i ]]; then
            echo &#34;Filename $i does not match colorname $colorname .. correcting &#34;
            sed -i.bak &#39;/colors_name/ s/.*/let g:colors_name=&#34;&#39;${i//.vim}&#39;&#34;/g&#39; $i
            #sed -i.bak &#39;s/(.*g:colors_name.*=)/1&#39;${i//.vim}&#39;/g&#39; $i
        fi
    fi
done

if [[ x$missing != x ]] ; then
    echo &#34;Missing colornames in $missing&#34;
fi&lt;/pre&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul zemanta-article-ul-image&#34; style=&#34;margin: 0; padding: 0; overflow: hidden;&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li-image zemanta-article-ul-li&#34; style=&#34;padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 84px; font-size: 11px; margin: 2px 10px 10px 2px;&#34;&gt;
    &lt;a style=&#34;box-shadow: 0px 0px 4px #999; padding: 2px; display: block; border-radius: 2px; text-decoration: none;&#34; href=&#34;http://java.dzone.com/articles/using-grep-inside-vim&#34; target=&#34;_blank&#34;&gt;&lt;img style=&#34;padding: 0; margin: 0; border: 0; display: block; width: 80px; max-width: 100%;&#34; alt=&#34;&#34; src=&#34;https://i0.wp.com/i.zemanta.com/204873595_80_80.jpg?w=688&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;&lt;a style=&#34;display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;&#34; href=&#34;http://java.dzone.com/articles/using-grep-inside-vim&#34; target=&#34;_blank&#34;&gt;Using Grep from Inside Vim&lt;/a&gt;
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li-image zemanta-article-ul-li&#34; style=&#34;padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 84px; font-size: 11px; margin: 2px 10px 10px 2px;&#34;&gt;
    &lt;a style=&#34;box-shadow: 0px 0px 4px #999; padding: 2px; display: block; border-radius: 2px; text-decoration: none;&#34; href=&#34;http://nathangrigg.net/vimhelp/&#34; target=&#34;_blank&#34;&gt;&lt;img style=&#34;padding: 0; margin: 0; border: 0; display: block; width: 80px; max-width: 100%;&#34; alt=&#34;&#34; src=&#34;https://i1.wp.com/i.zemanta.com/noimg_35_80_80.jpg?w=688&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;&lt;a style=&#34;display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;&#34; href=&#34;http://nathangrigg.net/vimhelp/&#34; target=&#34;_blank&#34;&gt;Vim&amp;#8217;s full help in PDF form&lt;/a&gt;
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li-image zemanta-article-ul-li&#34; style=&#34;padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 84px; font-size: 11px; margin: 2px 10px 10px 2px;&#34;&gt;
    &lt;a style=&#34;box-shadow: 0px 0px 4px #999; padding: 2px; display: block; border-radius: 2px; text-decoration: none;&#34; href=&#34;http://www.vim.org/scripts/script.php?script_id=4586&#34; target=&#34;_blank&#34;&gt;&lt;img style=&#34;padding: 0; margin: 0; border: 0; display: block; width: 80px; max-width: 100%;&#34; alt=&#34;&#34; src=&#34;https://i1.wp.com/i.zemanta.com/noimg_22_80_80.jpg?w=688&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;&lt;a style=&#34;display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;&#34; href=&#34;http://www.vim.org/scripts/script.php?script_id=4586&#34; target=&#34;_blank&#34;&gt;vim-colorscheme-switcher 0.2.5 &amp;#8212; Easily &amp; quickly switch between color schemes&lt;/a&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;</description>
    </item>
    
    <item>
      <title>dnsmasq not starting from NetworkManager with SELinux enabled.</title>
      <link>/2013/03/16/dnsmasq-starting-networkmanager-selinux-enabled/</link>
      <pubDate>Sat, 16 Mar 2013 11:34:11 +0000</pubDate>
      
      <guid>/2013/03/16/dnsmasq-starting-networkmanager-selinux-enabled/</guid>
      <description>&lt;figure style=&#34;width: 240px&#34; class=&#34;wp-caption alignright&#34;&gt;&lt;a href=&#34;http://www.flickr.com/photos/96408062@N00/3894034368&#34; target=&#34;_blank&#34;&gt;&lt;img class=&#34;zemanta-img-inserted zemanta-img-configured&#34; title=&#34;OpenWrt - Dnsmasq&#34; alt=&#34;OpenWrt - Dnsmasq&#34; src=&#34;https://i0.wp.com/farm3.static.flickr.com/2571/3894034368_2f9d8ec51b_m.jpg?resize=240%2C195&#34; width=&#34;240&#34; height=&#34;195&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;&lt;figcaption class=&#34;wp-caption-text&#34;&gt;OpenWrt &amp;#8211; Dnsmasq (Photo credit: magicfab)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Some time back I posted on &lt;a href=&#34;http://blog.amit-agarwal.co.in/2013/01/28/dnsmasq-network-manager/&#34; title=&#34;dnsmasq – use with Network Manager.&#34;&gt;dnsmasq starting from Network Manager&lt;/a&gt; and how to &lt;a href=&#34;http://blog.amit-agarwal.co.in/2010/04/30/local-dns-server-for-faster-dns-response-time/&#34; title=&#34;Local DNS Server for faster DNS response time&#34;&gt;setup dnsmasq&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now, couple of days back , I setup dnsmasq in &lt;a class=&#34;zem_slink&#34; title=&#34;NetworkManager&#34; href=&#34;http://projects.gnome.org/NetworkManager/&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;NetworkManager&lt;/a&gt; but was astonished to see that there was no dnsmasq running. I checked with dig and saw that there was no response from localhost for &lt;a class=&#34;zem_slink&#34; title=&#34;Domain Name System&#34; href=&#34;http://en.wikipedia.org/wiki/Domain_Name_System&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;dns&lt;/a&gt; queries. Checked “ps -eaf|&lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt; dns” and found that there was no dnsmasq running. I knew that once you mention “&lt;strong&gt;dns=dnsmasq&lt;/strong&gt;” in the NetworkManager then it should start up but that was not happening. And then I checked audit log, found that some permissions were denied by &lt;a class=&#34;zem_slink&#34; title=&#34;Security-Enhanced Linux&#34; href=&#34;http://en.wikipedia.org/wiki/Security-Enhanced_Linux&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;SELinux&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Disable a few cores when you want to save power.</title>
      <link>/2012/12/28/disable-cores-save-power/</link>
      <pubDate>Fri, 28 Dec 2012 01:23:46 +0000</pubDate>
      
      <guid>/2012/12/28/disable-cores-save-power/</guid>
      <description>&lt;p&gt;If you have a lot of &lt;a class=&#34;zem_slink&#34; title=&#34;Central processing unit&#34; href=&#34;http://en.wikipedia.org/wiki/Central_processing_unit&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;CPU&lt;/a&gt; power and working on battery. If you do not need that much of power and would like to rather save some &lt;a class=&#34;zem_slink&#34; title=&#34;Batteries drain rates infographics&#34; href=&#34;http://blog.lenovo.com/products/when-will-batteries-last-the-work-week?cid=us|425522&#34; target=&#34;_blank&#34; rel=&#34;lenovo&#34;&gt;battery power&lt;/a&gt; by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the &lt;a class=&#34;zem_slink&#34; title=&#34;For loop&#34; href=&#34;http://en.wikipedia.org/wiki/For_loop&#34; target=&#34;_blank&#34; rel=&#34;wikipedia&#34;&gt;for loop&lt;/a&gt;. You would need the &lt;a class=&#34;zem_slink&#34; title=&#34;Sudo&#34; href=&#34;http://www.sudo.ws&#34; target=&#34;_blank&#34; rel=&#34;homepage&#34;&gt;sudo&lt;/a&gt; to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>BASH Script Performace</title>
      <link>/2012/01/06/bash-script-performace/</link>
      <pubDate>Fri, 06 Jan 2012 06:38:04 +0000</pubDate>
      
      <guid>/2012/01/06/bash-script-performace/</guid>
      <description>&lt;p&gt;Today we will look at some bash code snippests and the performance issues. Lets first look at the problem and the implemented solution:&lt;/p&gt;
&lt;p&gt;Problem: We needed to log the output of the ps command for all the process’s. This was required to be done on per minute basis and the output was required in comma separated files. So, here is what was implemented:&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;pslog=`ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcp:u,args|grep -v PID|sort -r -k 13,13`
        OLD_IFS=$IFS
        IFS=$&#39;\n&#39;
        logarr=( $pslog )
        for LOGLINE in ${logarr[@]}
        do
                LOGLINE=`echo $LOGLINE|awk &#39;{OFS=&#34;,&#34;;print $1,$2,$3,$4,$5,$6,$7,:$8,$9,$10,$11,$12,$13,$14}&#39;`
                echo $LOGLINE &amp;gt;&amp;gt; output
        done
        IFS=$OLD_IFS&lt;/pre&gt;
&lt;p&gt;This was working well and there were no issues. But suddenly we started seeing issues with the reported &lt;a class=&#34;zem_slink&#34; title=&#34;Central processing unit&#34; href=&#34;http://en.wikipedia.org/wiki/Central_processing_unit&#34; rel=&#34;wikipedia&#34;&gt;CPU&lt;/a&gt; usages. We would see that whenever this script was running the &lt;a class=&#34;zem_slink&#34; title=&#34;CPU time&#34; href=&#34;http://en.wikipedia.org/wiki/CPU_time&#34; rel=&#34;wikipedia&#34;&gt;CPU usage&lt;/a&gt; was high, specially if there were too many process’s/thread’s on the system during that time.  This code was definitely part of a very large &lt;a class=&#34;zem_slink&#34; title=&#34;Codebase&#34; href=&#34;http://en.wikipedia.org/wiki/Codebase&#34; rel=&#34;wikipedia&#34;&gt;code base&lt;/a&gt;, and at this point of time we did not know what was causing the issues.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Rekursive Grep on Solaris or AIX Systems without GNU egrep -r funcionality</title>
      <link>/2011/12/16/rekursive-grep-solaris-aix-systems-gnu-egrep-r-funcionality/</link>
      <pubDate>Fri, 16 Dec 2011 03:00:27 +0000</pubDate>
      
      <guid>/2011/12/16/rekursive-grep-solaris-aix-systems-gnu-egrep-r-funcionality/</guid>
      <description>&lt;p&gt;If you work regularly on a &lt;a class=&#34;zem_slink&#34; title=&#34;Solaris (operating system)&#34; href=&#34;http://oracle.com/solaris&#34; rel=&#34;homepage&#34;&gt;Solaris&lt;/a&gt; or systems which do not have the “-r” (recursive &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt;) for grep, then you know what a lifesaver this command can be.&lt;/p&gt;
&lt;p&gt;Here is one from &lt;a class=&#34;zem_slink&#34; title=&#34;Command-line interface&#34; href=&#34;http://en.wikipedia.org/wiki/Command-line_interface&#34; rel=&#34;wikipedia&#34;&gt;command line&lt;/a&gt; fu:&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;find . -type f -exec awk &#39;/linux/ { printf &#34;%s %s: %s\n&#34;, FILENAME, NR, $0; }&#39; {} \;&lt;/pre&gt;
&lt;p&gt;The benefit of using awk here is that you can print the line number also 🙂&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Linux hardware details.</title>
      <link>/2011/11/28/linux-hardware-details/</link>
      <pubDate>Mon, 28 Nov 2011 11:20:25 +0000</pubDate>
      
      <guid>/2011/11/28/linux-hardware-details/</guid>
      <description>&lt;p&gt;Here is one of the scripts that I found on the net while searching for something … Note the &lt;a class=&#34;zem_slink&#34; title=&#34;Uniform Resource Locator&#34; href=&#34;http://en.wikipedia.org/wiki/Uniform_Resource_Locator&#34; rel=&#34;wikipedia&#34;&gt;URL&lt;/a&gt; for the script in the Description.&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;#!/bin/bash -
#===============================================================================
#
#          FILE:  linux_hw.sh
#
#         USAGE:  ./linux_hw.sh
#
#   DESCRIPTION:  http://www.howtogeek.com/howto/solaris/get-the-processor-type-on-solaris/
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: &lt;a class=&#34;zem_slink&#34; title=&#34;Amit Agarwal&#34; href=&#34;http://www.labnol.org/about/&#34; rel=&#34;homepage&#34;&gt;Amit Agarwal&lt;/a&gt; (aka), amit.agarwal@roamware.com
#       COMPANY: Roamware India Pvt Ltd
#       CREATED: 09/13/2011 03:57:34 PM IST
# Last modified: Sun Oct 30, 2011  04:59PM
#      REVISION:  ---
#===============================================================================

function linux_hw_CPU {
	&lt;a class=&#34;zem_slink&#34; title=&#34;Typesetting&#34; href=&#34;http://en.wikipedia.org/wiki/Typesetting&#34; rel=&#34;wikipedia&#34;&gt;typeset&lt;/a&gt; num=0
	typeset name=&#34;&#34;
	typeset cores=&#34;&#34;
	name=&#34;$( cat &lt;a class=&#34;zem_slink&#34; title=&#34;Procfs&#34; href=&#34;http://en.wikipedia.org/wiki/Procfs&#34; rel=&#34;wikipedia&#34;&gt;/proc/cpuinfo&lt;/a&gt; | awk -F: &#39;
/vendor_id/ { vendor=$2 }
/model name/ { model=$2 }
/cpu &lt;a class=&#34;zem_slink&#34; title=&#34;Hertz&#34; href=&#34;http://en.wikipedia.org/wiki/Hertz&#34; rel=&#34;wikipedia&#34;&gt;MHz&lt;/a&gt;/ {
if( model ~ &#34;Hz&#34; ) {speed=&#34;&#34;} else { speed=$2? MHz&#34; };
print vendor, model, speed; }
		&#39; | tail -1
	)&#34;

        num=$(if [ -r /proc/vmware/cpuinfo ]; then awk &#39;/pcpu/ { print NF-1 }&#39; /proc/vmware/cpuinfo; else cat /proc/cpuinfo | &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34; rel=&#34;wikipedia&#34;&gt;grep&lt;/a&gt; processor| wc -l; fi)

	# ESX: mas info sobre logical/cores/packages
	if [ -r /proc/vmware/sched/ncpus ]
	then
		cores=$( echo $( cat /proc/vmware/sched/ncpus ) )
	fi

	echo $num $( echo &#34;$name ($cores)&#34; | enclose )
}

function enclose {
	tr -s &#34; &#34; | sed -e &#34;s/^/\&#34;/; s/$/\&#34;/; s/\&#34;\ /\&#34;/; s/\ \&#34;/\&#34;/&#34;
}

function linux_hw_CPU {

	typeset num=0
	typeset name=&#34;&#34;
	typeset cores=&#34;&#34;

	name=&#34;$(
		cat /proc/cpuinfo | awk -F: &#39;
/vendor_id/ { vendor=$2 }
/model name/ { model=$2 }
/cpu MHz/ {
if( model ~ &#34;Hz&#34; ) {speed=&#34;&#34;} else { speed=$2&#34; MHz&#34; };
print vendor, model, speed; }
		&#39; | tail -1
	)&#34;

	num=$(
		if [ -r /proc/vmware/cpuinfo ]
		then
			awk &#39;/pcpu/ { print NF-1 }&#39; /proc/vmware/cpuinfo
		else
			cat /proc/cpuinfo | grep processor| wc -l
		fi

	)

	if grep -q &#34;physical id&#34; /proc/cpuinfo || grep &#34;siblings&#34; /proc/cpuinfo
	then
		chip_count=$( grep &#34;physical id&#34; /proc/cpuinfo | sort -u | wc -l )
		chip_core=$( grep &#34;siblings&#34; /proc/cpuinfo | tail -1 | cut -d: -f2 )
		cores=&#34;($chip_count chips x $chip_core cores)&#34;
	fi

	# Blades HP con
	if [ -x /sbin/hpasmcli ]
	then
		chip_name=$( /sbin/hpasmcli -s &#34;SHOW &lt;a class=&#34;zem_slink&#34; title=&#34;Server (computing)&#34; href=&#34;http://en.wikipedia.org/wiki/Server_%28computing%29&#34; rel=&#34;wikipedia&#34;&gt;SERVER&lt;/a&gt;&#34; | grep &#34;Name&#34; | head -1 | cut -d: -f2 )
		chip_speed=$( /sbin/hpasmcli -s &#34;SHOW SERVER&#34; | grep &#34;Speed&#34; | head -1 | cut -d: -f2 )
		chip_core=$( /sbin/hpasmcli -s &#34;SHOW SERVER&#34; | grep &#34;Core&#34; | head -1 | cut -d: -f2 )
	fi

	# ESX: mas info sobre logical/cores/packages
	if [ -r /proc/vmware/sched/ncpus ]
	then
		cores=&#34;($( echo $( cat /proc/vmware/sched/ncpus ) ))&#34;
	fi

	# &lt;a class=&#34;zem_slink&#34; title=&#34;Linux&#34; href=&#34;http://www.kernel.org/&#34; rel=&#34;homepage&#34;&gt;Linux&lt;/a&gt; &lt;a class=&#34;zem_slink&#34; title=&#34;Itanium&#34; href=&#34;http://en.wikipedia.org/wiki/Itanium&#34; rel=&#34;wikipedia&#34;&gt;Itanium&lt;/a&gt; IA64
	if grep -q -i itanium /proc/cpuinfo
	then
		name=&#34;$(
		grep &#34;vendor&#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;arch &#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;family&#34; /proc/cpuinfo | cut -d: -f2- | tail -1 ) $(
		grep &#34;cpu MHz&#34; /proc/cpuinfo | cut -d: -f2- | cut -d. -f1 | tail -1 ) Mhz&#34;

		chip_count=$( grep &#34;physical id&#34; /proc/cpuinfo | sort -u | wc -l )
		chip_core=$( grep &#34;siblings&#34; /proc/cpuinfo | tail -1 | cut -d: -f2 )
		cores=&#34;($chip_count chips x $chip_core cores)&#34;
	fi

	echo $num $( echo &#34;$name $cores&#34; | enclose )
}

linux_hw_CPU&lt;/pre&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://weijianhui16.wordpress.com/2011/09/06/linux%e6%9f%a5%e7%9c%8b%e7%a1%ac%e4%bb%b6%e4%bf%a1%e6%81%af/&#34;&gt;linux??????&lt;/a&gt; (weijianhui16.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://singztechmusings.wordpress.com/2011/06/15/how-to-check-the-uptime-of-a-process-or-an-application-running-in-linux-machine-using-shell-script/&#34;&gt;How to check the uptime of a process (or an application) running in Linux machine using shell script?&lt;/a&gt; (singztechmusings.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://javarevisited.wordpress.com/2011/06/15/good-examples-of-grep-command-in-unix-and-linux/&#34;&gt;Some examples of grep command in unix&lt;/a&gt; (javarevisited.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34;&gt;
  &lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;
&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>some interesting alias</title>
      <link>/2011/09/27/interesting-alias/</link>
      <pubDate>Tue, 27 Sep 2011 07:43:01 +0000</pubDate>
      
      <guid>/2011/09/27/interesting-alias/</guid>
      <description>&lt;p&gt;For this time, I will just give you a link to to bashrc file.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://hayne.net/MacDev/Bash/aliases.bash&#34;&gt;http://hayne.net/MacDev/Bash/aliases.bash&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Head over there and see some very interesting aliase’s.&lt;/p&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://bryanquigley.com/uncategorized/windows-cant-handle-the-hardware&#34;&gt;Bryan Quigley: Windows Cant Handle the Hardware&lt;/a&gt; (bryanquigley.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;https://github.com/regit/coccigrep&#34;&gt;semantic grep&lt;/a&gt; (github.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://macstarter.com/2011/06/30/aliases-and-shortcuts/&#34;&gt;Aliases and shortcuts&lt;/a&gt; (macstarter.com)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34;&gt;
  &lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;
&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Total upload and download on any interface.</title>
      <link>/2011/06/05/total-upload-download-interface/</link>
      <pubDate>Sun, 05 Jun 2011 01:29:21 +0000</pubDate>
      
      <guid>/2011/06/05/total-upload-download-interface/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Something that I have been searching for a long time, finally some look inside the &amp;lt;a class=&amp;ldquo;zem_slink&amp;rdquo; title=&amp;ldquo;Procfs&amp;rdquo; rel=&amp;ldquo;wikipedia&amp;rdquo; href=&amp;ldquo;&lt;a href=&#34;http://en.wikipedia.org/wiki/Procfs%22&#34;&gt;http://en.wikipedia.org/wiki/Procfs&amp;quot;&lt;/a&gt; _mce_href=&amp;ldquo;&lt;a href=&#34;http://en.wikipedia.org/wiki/Procfs%22%3E/proc&#34;&gt;http://en.wikipedia.org/wiki/Procfs&amp;quot;&amp;gt;/proc&lt;/a&gt;&lt;/a&gt; got me what I wanted. Hope this will save someone’s day. So far, the only option I could think of was to run conky which becomes a little heave on some of the very old laptops I have to use sometimes 🙁&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      &amp;amp;nbsp;cat /proc/net/dev|grep eth2|awk &#39;{print $2/1024/1024&amp;quot;&amp;amp;nbsp; &amp;quot;$10/1024/1024}&#39;
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34; \_mce\_style=&#34;font-size: 1em;&#34;&gt;Related articles&lt;/h6&gt; 
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://jarneil.wordpress.com/2011/03/15/cpuspeed-slowing-you-down/&#34; _mce_href=&#34;http://jarneil.wordpress.com/2011/03/15/cpuspeed-slowing-you-down/&#34;&gt;CPUSPEED Slowing you down?&lt;/a&gt; (jarneil.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://lingpipe-blog.com/2011/05/26/interface-curmudgeons/&#34; _mce_href=&#34;http://lingpipe-blog.com/2011/05/26/interface-curmudgeons/&#34;&gt;Interface Curmudgeons versus Gestures&lt;/a&gt; (lingpipe-blog.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://michaeldaranto.wordpress.com/2011/05/28/alias-in-bashrc/&#34; _mce_href=&#34;http://michaeldaranto.wordpress.com/2011/05/28/alias-in-bashrc/&#34;&gt;Alias in .bashrc&lt;/a&gt; (michaeldaranto.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34; \_mce\_style=&#34;margin-top: 10px; height: 15px;&#34;&gt;&lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34; \_mce\_href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;border: medium none; float: right;&#34; \_mce\_style=&#34;border: medium none; float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified\_e.png?w=688&#34; \_mce\_src=&#34;https://i1.wp.com/img.zemanta.com/zemified\_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34;/&gt;&lt;/a&gt;&lt;br \_mce\_bogus=&#34;1&#34;/&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Ranking of the most frequently used commands</title>
      <link>/2011/02/01/ranking-frequently-commands/</link>
      <pubDate>Mon, 31 Jan 2011 22:54:43 +0000</pubDate>
      
      <guid>/2011/02/01/ranking-frequently-commands/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Lets take a quick look at how to get the most frequently used commands on you shell. So what we need to do is this:&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      history | awk &#39;{print $2}&#39; | awk &#39;BEGIN {FS=&amp;quot;|&amp;quot;}{print $1}&#39; | sort | uniq -c | sort -n | tail | sort -nr
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;So, how did we arrive at this and will this always work? No it might not always work. A typical example is where HISTTIMEFORMAT variable is set. In that case, if you check history, you will see that after the number column we have &lt;a class=&#34;zem_slink&#34; title=&#34;Time and date&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Time_and_date&#34;&gt;time and date&lt;/a&gt; in the specified format, in which case, you will get wrong information from the above command. Anyways, forgetting these special cases, lets go to how we got this command:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>write the output of a command to /var/log/user.log… each line will contain $USER, making this easy to grep for.</title>
      <link>/2010/12/28/write-output-command-varloguserlog-line-user-making-easy-grep/</link>
      <pubDate>Tue, 28 Dec 2010 15:00:24 +0000</pubDate>
      
      <guid>/2010/12/28/write-output-command-varloguserlog-line-user-making-easy-grep/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;write the &lt;a class=&#34;zem_slink&#34; title=&#34;Output&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Output&#34;&gt;output&lt;/a&gt; of a &lt;a class=&#34;zem_slink&#34; title=&#34;Command (computing)&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Command_%28computing%29&#34;&gt;command&lt;/a&gt; to /var/log/user.log… each line will contain $USER, making this easy to &lt;a class=&#34;zem_slink&#34; title=&#34;Grep&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Grep&#34;&gt;grep&lt;/a&gt; for.&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      &amp;amp;nbsp;log() { (echo &amp;quot;$ $@&amp;quot;;$@) | logger -t $USER; }
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;This command is useful if you want to copy the output of a series of commands to a file, for example if you want to pastebin the output from ‘&lt;a class=&#34;zem_slink&#34; title=&#34;Uname&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Uname&#34;&gt;uname&lt;/a&gt; -a’, ‘lspci -vvv’ and ‘lsmod’ for video driver trouble-shooting on your favorite &lt;a class=&#34;zem_slink&#34; title=&#34;Linux&#34; rel=&#34;homepage&#34; href=&#34;http://www.kernel.org/&#34;&gt;Linux&lt;/a&gt; forum.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>function for copy files with progress bar (using pv – pipe viewer)</title>
      <link>/2010/11/11/function-copy-files-progress-bar-pv-pipe-viewer/</link>
      <pubDate>Thu, 11 Nov 2010 03:43:43 +0000</pubDate>
      
      <guid>/2010/11/11/function-copy-files-progress-bar-pv-pipe-viewer/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;function for copy &lt;a class=&#34;zem_slink&#34; title=&#34;Computer file&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Computer_file&#34;&gt;files&lt;/a&gt; with &lt;a class=&#34;zem_slink&#34; title=&#34;Progress bar&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Progress_bar&#34;&gt;progress bar&lt;/a&gt; (using pv – pipe viewer)&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      &amp;amp;nbsp;cp_p() { if [ `echo &amp;quot;$2&amp;quot; | grep &amp;quot;.*/$&amp;quot;` ]; then pv &amp;quot;$1&amp;quot; &amp;gt; &amp;quot;$2&amp;quot;&amp;quot;$1&amp;quot;; else pv &amp;quot;$1&amp;quot; &amp;gt; &amp;quot;$2&amp;quot;/&amp;quot;$1&amp;quot;; fi; }
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;dont have to type new file name (it copy file under same name) and dont have to use ‘/’ in the end of destination folder (but you can if u want, its &lt;a class=&#34;zem_slink&#34; title=&#34;Idiot proof&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Idiot_proof&#34;&gt;idiot proof&lt;/a&gt;)&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Remove some path from the PATH variable temporarily.</title>
      <link>/2010/09/04/remove-path-path-variable-temporarily/</link>
      <pubDate>Sat, 04 Sep 2010 15:02:08 +0000</pubDate>
      
      <guid>/2010/09/04/remove-path-path-variable-temporarily/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;How many times has it happened to you that you are working on some linux platform (like Fedora/Ubuntu/CentOS etc) and suddenly you see that you need to remove some path from the PATH variable so that a script is executed from some other path. It really difficult to do this if the path is too long and if you end up doing this couple of times. If that is the case, then the below script is for you 🙂&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>regular expression, sed and grep tuturials and tricks.</title>
      <link>/2010/06/17/regular-expression-sed-and-grep-tuturials-and-tricks/</link>
      <pubDate>Thu, 17 Jun 2010 15:56:53 +0000</pubDate>
      
      <guid>/2010/06/17/regular-expression-sed-and-grep-tuturials-and-tricks/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Simply a great one page article on sed and use of regular expressions.&lt;/p&gt;
&lt;p&gt;&amp;lt;a href=&amp;quot;http://almirkaric.com/2009/07/15/sed-and-grep-tips/&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;http://almirkaric.com/2009/07/15/sed-and-grep-tips/&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Determine what process is listening on a port on Solaris, without lsof</title>
      <link>/2010/06/08/determine-what-process-is-listening-on-a-port-on-solaris-without-lsof/</link>
      <pubDate>Tue, 08 Jun 2010 09:13:37 +0000</pubDate>
      
      <guid>/2010/06/08/determine-what-process-is-listening-on-a-port-on-solaris-without-lsof/</guid>
      <description>&lt;div class=\&#34;zemanta-img\&#34;&gt; 
&lt;div&gt;
  &lt;dl class=\&#34;wp-caption alignright\&#34;&gt; &lt;dt class=\&#34;wp-caption-dt\&#34;&gt;&lt;a href=\&#34;http://www.flickr.com/photos/24543279@N04/3913703678\&#34;&gt;&lt;img title=\&#34;Desktop September 2009 (Mac)\&#34; src=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/3913703678_a6912b45d0_m.jpg\&#34; alt=\&#34;Desktop September 2009 (Mac)\&#34; /&gt;&lt;/a&gt;&lt;/dt&gt; &lt;dd class=\&#34;wp-caption-dd zemanta-img-attribution\&#34;&gt;Image by &lt;a href=\&#34;http://www.flickr.com/photos/24543279@N04/3913703678\&#34;&gt;Metsuke iLife&lt;/a&gt; via Flickr&lt;/dd&gt; &lt;/dl&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;$ for x in `ptree | &amp;lt;a class=&amp;quot;zem_slink freebase/en/awk&amp;quot; title=&amp;quot;AWK&amp;quot; rel=&amp;quot;homepage&amp;quot; href=&amp;quot;http://cm.bell-labs.com/cm/cs/awkbook/index.html&amp;quot;&amp;gt;awk&lt;/a&gt; &#39;{print $1}&amp;amp;#8217;`; do pfiles $x | &amp;lt;a class=&amp;quot;zem_slink freebase/en/grep&amp;quot; title=&amp;quot;Grep&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Grep&amp;quot;&amp;gt;grep&lt;/a&gt; ${PORT} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1; if [ x&amp;amp;#8221;$?&amp;amp;#8221; == &amp;amp;#8221;x0&amp;amp;#8221; ]; then ps -ef | grep $x | grep -v grep; fi; done 2&amp;gt; /dev/null&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>vim – get the list of all the scripts available.</title>
      <link>/2010/05/28/vim-get-the-list-of-all-the-scripts-available/</link>
      <pubDate>Thu, 27 May 2010 20:26:35 +0000</pubDate>
      
      <guid>/2010/05/28/vim-get-the-list-of-all-the-scripts-available/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;To get a list of all the scripts in the vim.sf.net project, you can run the following command. This will list all the scripts with the script id.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;wget -O – &amp;amp;#8217;http://www.vim.org/scripts/script_search_results.php?&amp;amp;show_me=4000&amp;amp;result_ptr=0&amp;amp;#8217; -o /dev/null | &amp;lt;a class=&amp;quot;zem_slink freebase/en/grep&amp;quot; title=&amp;quot;Grep&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Grep&amp;quot;&amp;gt;grep&lt;/a&gt; width| grep script_id= |&amp;lt;a class=&amp;quot;zem_slink freebase/en/sed&amp;quot; title=&amp;quot;Sed&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Sed&amp;quot;&amp;gt;sed&lt;/a&gt; &amp;amp;#8217;s/.*script_id=//&amp;amp;#8217;|tr -d &amp;amp;#8221;&amp;amp;#8221;&amp;amp;#8221;|tr &amp;amp;#8221;&amp;gt;&amp;amp;#8221; &amp;amp;#8221; &amp;amp;#8221;|sed &amp;amp;#8217;s/&amp;lt; .*//&amp;amp;#8217; | tr -d &amp;amp;#8217;\001&amp;amp;#8217;-&amp;amp;#8217;\011&amp;amp;#8217;&amp;amp;#8217;\013&amp;amp;#8217;&amp;amp;#8217;\014&amp;amp;#8217;&amp;amp;#8217;\016&amp;amp;#8217;-&amp;amp;#8217;\037&amp;amp;#8217;&amp;amp;#8217;\200&amp;amp;#8217;-&amp;amp;#8217;\377&amp;amp;#8217; |sort -n&amp;lt;h6 class=&amp;quot;zemanta-related-title&amp;quot;&amp;gt;Related articles by Zemanta&lt;/h6&gt; &amp;lt;ul class=&amp;quot;zemanta-article-ul&amp;quot;&amp;gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.slumpedoverkeyboarddead.com/2009/09/17/use-curl-to-monitor-your-vonage-phone-bill/&amp;quot;&amp;gt;Use curl to Monitor Your Vonage Phone Bill&lt;/a&gt; (slumpedoverkeyboarddead.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://securewebs.com/yum-updates/&amp;quot;&amp;gt;Yum Updates&lt;/a&gt; (securewebs.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.gubatron.com/blog/2009/10/10/ubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line/&amp;quot;&amp;gt;Ubuntu/Debian Quick Reference: How To Change Your Server&amp;amp;#8217;s UTC Timezone on the command line&lt;/a&gt; (gubatron.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://blog.amit-agarwal.co.in/2009/11/22/short-information-about-loaded-kernel-modules/&amp;quot;&amp;gt;Short Information about loaded kernel modules&lt;/a&gt; (amit-agarwal.co.in)&lt;/li&gt; &lt;/ul&gt; &amp;lt;div class=&amp;quot;zemanta-pixie&amp;quot;&amp;gt;&amp;lt;a class=&amp;quot;zemanta-pixie-a&amp;quot; title=&amp;quot;Reblog this post [with Zemanta]&amp;quot; href=&amp;quot;http://reblog.zemanta.com/zemified/b22b2e85-8107-4f9b-9130-85a8e8ae370b/&amp;quot;&amp;gt;&amp;lt;img class=&amp;quot;zemanta-pixie-img&amp;quot; src=&amp;quot;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b52.png&amp;quot; alt=&amp;quot;Reblog this post [with Zemanta]&amp;quot; /&amp;gt;&lt;/a&gt;&amp;lt;span class=&amp;quot;zem-script more-related more-info pretty-attribution paragraph-reblog&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>more powerful grep – ack</title>
      <link>/2010/05/26/more-powerful-grep-ack/</link>
      <pubDate>Wed, 26 May 2010 11:41:56 +0000</pubDate>
      
      <guid>/2010/05/26/more-powerful-grep-ack/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;For last couple of days, I have been using ack instead of grep. Here is description of ack:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ack is designed as a replacement for grep.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There are couple of reasons I am using ack. First and foremost being it does not require a filename. So, for seaching amit in all files recursively under the current directory I can simply use&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ack amit&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;More reasons to use ack:&lt;/p&gt;
&lt;p&gt;It supports pager option and there can be a rc file that can be used to define the default options that needs to be used with ack. Here is the contents of my &lt;strong&gt;$HOME/.ackrc&lt;/strong&gt; file.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Script to download all the related videos from youtube with youtube-dl</title>
      <link>/2010/05/17/script-download-related-videos-youtube-youtubedl/</link>
      <pubDate>Mon, 17 May 2010 15:59:20 +0000</pubDate>
      
      <guid>/2010/05/17/script-download-related-videos-youtube-youtubedl/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Lets cut the long discussion &amp;lt;a class=&amp;quot;zem_slink freebase/en/short_subject&amp;quot; title=&amp;quot;Short film&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Short_film&amp;quot;&amp;gt;short&lt;/a&gt; and directly give you the script. The script is combination of all the posts that I did in the past about youtube &amp;lt;a class=&amp;quot;zem_slink freebase/en/uploading_and_downloading&amp;quot; title=&amp;quot;Uploading and downloading&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Uploading_and_downloading&amp;quot;&amp;gt;downloads&lt;/a&gt;. You need to copy all the &amp;lt;a class=&amp;quot;zem_slink freebase/en/uniform_resource_locator&amp;quot; title=&amp;quot;Uniform Resource Locator&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Uniform_Resource_Locator&amp;quot;&amp;gt;URL&lt;/a&gt;&amp;amp;#8217;s in a file called &amp;amp;#8221;&lt;strong&gt;~/youtube.urls&lt;/strong&gt;&amp;amp;#8221; which you want to be downloaded. Or if you need to donwload the related videos, then save the html of the page and give it as the first argument for the script. So, here&amp;amp;#8217;s the scrit:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Downloading all related videos from youtube with youtube-dl</title>
      <link>/2010/05/16/downloading-related-videos-youtube-youtubedl/</link>
      <pubDate>Sun, 16 May 2010 15:53:16 +0000</pubDate>
      
      <guid>/2010/05/16/downloading-related-videos-youtube-youtubedl/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;How many time did you want to see all the videos (related) to the one you were watching on youtube but decided otherwise as the downloaded was not fast enough. Or has it happened to you that you wanted to &amp;lt;a class=&amp;quot;zem_slink freebase/en/uploading_and_downloading&amp;quot; title=&amp;quot;Uploading and downloading&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Uploading_and_downloading&amp;quot;&amp;gt;download&lt;/a&gt; all the related videos, in either case you can use the youtube-dl utility I blogged about some times back. First you need to get all the &amp;lt;a class=&amp;quot;zem_slink freebase/en/uniform_resource_locator&amp;quot; title=&amp;quot;Uniform Resource Locator&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Uniform_Resource_Locator&amp;quot;&amp;gt;URL&lt;/a&gt;&amp;amp;#8217;s in a &amp;lt;a class=&amp;quot;zem_slink freebase/en/text_file&amp;quot; title=&amp;quot;Text file&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Text_file&amp;quot;&amp;gt;text file&lt;/a&gt;, and the simplest way to do this is :&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Script to get the number of events from the logs.</title>
      <link>/2010/04/11/script-to-get-the-number-of-events-from-the-logs/</link>
      <pubDate>Sun, 11 Apr 2010 09:11:49 +0000</pubDate>
      
      <guid>/2010/04/11/script-to-get-the-number-of-events-from-the-logs/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;&amp;lt;a id=&amp;quot;aptureLink_4P0PJ73NaG&amp;quot; style=&amp;quot;margin: 0pt auto; padding: 0px 6px; text-align: center; display: block;&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Log%20analysis&amp;quot;&amp;gt;&amp;lt;img style=&amp;quot;border: 0px none;&amp;quot; title=&amp;quot;Log analysis&amp;quot; src=&amp;quot;http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/360x320_WikipediaArticle&amp;quot; alt=&amp;quot;&amp;quot; width=&amp;quot;360px&amp;quot; height=&amp;quot;320px&amp;quot; /&amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I was trying to do some &amp;lt;a class=&amp;quot;zem_slink freebase/en/log_analysis&amp;quot; title=&amp;quot;Log analysis&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Log_analysis&amp;quot;&amp;gt;log analysis&lt;/a&gt; and finding the events in the logs. For this the logs had the Events logged as &amp;amp;#8221;|+Event name|&amp;amp;#8221; or with sending and receiving. So I wrote this little script to take care of my requirements.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Extract all urls from the last firefox sessionstore.js file used.</title>
      <link>/2010/03/29/extract-all-urls-from-the-last-firefox-sessionstore-js-file-used/</link>
      <pubDate>Mon, 29 Mar 2010 07:01:08 +0000</pubDate>
      
      <guid>/2010/03/29/extract-all-urls-from-the-last-firefox-sessionstore-js-file-used/</guid>
      <description>&lt;div class=\&#34;zemanta-img\&#34;&gt; 
&lt;div&gt;
  &lt;dl class=\&#34;wp-caption alignright\&#34;&gt; &lt;dt class=\&#34;wp-caption-dt\&#34;&gt;&lt;a href=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/03/Image:EffectivePerlBookCover.jpg\&#34;&gt;&lt;img title=\&#34;Effective Perl Programming\&#34; src=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/300px-EffectivePerlBookCover.jpg\&#34; alt=\&#34;Effective Perl Programming\&#34; /&gt;&lt;/a&gt;&lt;/dt&gt; &lt;dd class=\&#34;wp-caption-dd zemanta-img-attribution\&#34;&gt;Image via &lt;a href=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/03/Image:EffectivePerlBookCover.jpg\&#34;&gt;Wikipedia&lt;/a&gt;&lt;/dd&gt; &lt;/dl&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Some taken from commandlinefu. What all the below commands are doing is basically that the url: is captured from the sessionstore.js file and then just  extract the URL from the line. These are done in various ways using perl, &amp;lt;a class=&amp;quot;zem_slink freebase/en/sed&amp;quot; title=&amp;quot;Sed&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Sed&amp;quot;&amp;gt;sed&lt;/a&gt; and &amp;lt;a class=&amp;quot;zem_slink freebase/en/awk&amp;quot; title=&amp;quot;AWK&amp;quot; rel=&amp;quot;homepage&amp;quot; href=&amp;quot;http://cm.bell-labs.com/cm/cs/awkbook/index.html&amp;quot;&amp;gt;awk&lt;/a&gt;:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>vim search multiple files</title>
      <link>/2010/03/25/vim-search-multiple-files/</link>
      <pubDate>Thu, 25 Mar 2010 02:41:28 +0000</pubDate>
      
      <guid>/2010/03/25/vim-search-multiple-files/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Searching some pattern in multiple files is something that is required very often. There are multiple ways to do it, like &amp;lt;a class=&amp;quot;zem_slink freebase/en/grep&amp;quot; title=&amp;quot;Grep&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Grep&amp;quot;&amp;gt;grep&lt;/a&gt;, &amp;lt;a class=&amp;quot;zem_slink freebase/guid/9202a8c04000641f8000000006b66ec6&amp;quot; title=&amp;quot;Ack (command-line utility)&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Ack_%28command-line_utility%29&amp;quot;&amp;gt;ack&lt;/a&gt;, find and so on so forth. But if your editor already has the capability to do that, then why leave your favourite vi and go to shell. I will point you to some scripts and some wiki pages on how to do this 🙂&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Color in grep output to distinquish the matching entries</title>
      <link>/2010/02/04/color-in-grep-output-to-distinquish-the-matching-entries/</link>
      <pubDate>Thu, 04 Feb 2010 15:58:35 +0000</pubDate>
      
      <guid>/2010/02/04/color-in-grep-output-to-distinquish-the-matching-entries/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Most of the times I end up spending a lot of time to look for the string in the grep output when I do a search. This is quite frustrating and thus I looked at the options for grep command that would make my life easier and there definately is something. Here it is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;export GREP_COLOR=&amp;amp;#8221;5;36&amp;amp;#8221;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;But for this to work you would still need to give the &amp;amp;#8221;–color=auto&amp;amp;#8221; option in the grep command. There are two ways to do this, create a alias for grep as &amp;amp;#8221;grep –color=auto&amp;amp;#8221; or specify the same in GREPOPTIONS.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>grep -v with multiple patterns.</title>
      <link>/2010/01/25/grep-v-with-multiple-patterns/</link>
      <pubDate>Mon, 25 Jan 2010 15:10:33 +0000</pubDate>
      
      <guid>/2010/01/25/grep-v-with-multiple-patterns/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;&lt;tt&gt;$ sed &#39;/test/{/error|critical|warning/d}&#39; somefile&lt;/tt&gt; If you wanted to do all in one command, you could go w/ sed instead&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&amp;lt;a href=&amp;quot;http://www.commandlinefu.com/commands/view/3882/grep-v-with-multiple-patterns.&amp;quot;&amp;gt;View this command to comment, vote or add to favourites&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&amp;lt;a href=&amp;quot;http://feeds2.feedburner.com/commands/by/pipping&amp;quot;&amp;gt;View all commands by &lt;/a&gt;&lt;strong&gt;&amp;lt;a href=&amp;quot;http://feeds2.feedburner.com/commands/by/pipping&amp;quot;&amp;gt;pipping&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;a href=&amp;quot;http://www.commandlinefu.com&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg&amp;quot; alt=&amp;quot;&amp;quot; align=&amp;quot;bottom&amp;quot; /&amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;by David Winterbottom (&amp;lt;a href=&amp;quot;http://codeinthehole.com&amp;quot;&amp;gt;codeinthehole.com&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&amp;lt;a href=&amp;quot;http://feedads.g.doubleclick.net/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/0/da&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/0/di&amp;quot; alt=&amp;quot;&amp;quot; align=&amp;quot;bottom&amp;quot; /&amp;gt;&lt;/a&gt;&lt;br&gt;
&amp;lt;a href=&amp;quot;http://feedads.g.doubleclick.net/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/1/da&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/1/di&amp;quot; alt=&amp;quot;&amp;quot; align=&amp;quot;bottom&amp;quot; /&amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;img src=&amp;quot;http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/LjKzo7FpzDU&amp;quot; alt=&amp;quot;&amp;quot; width=&amp;quot;1&amp;quot; height=&amp;quot;1&amp;quot; align=&amp;quot;bottom&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;URL: &amp;lt;a href=&amp;quot;http://feedproxy.google.com/~r/Command-line-fu/~3/LjKzo7FpzDU/grep-v-with-multiple-patterns.&amp;quot;&amp;gt;http://feedproxy.google.com/~r/Command-line-fu/~3/LjKzo7FpzDU/grep-v-with-multiple-patterns.&lt;/a&gt;&amp;lt;h6 class=&amp;quot;zemanta-related-title&amp;quot; style=&amp;quot;font-size: 1em;&amp;quot;&amp;gt;Related articles by Zemanta&lt;/h6&gt; &amp;lt;ul class=&amp;quot;zemanta-article-ul&amp;quot;&amp;gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.seroundtable.com/archives/020935.html&amp;quot;&amp;gt;Google&amp;amp;#8217;s &amp;amp;#8221;Show More Results&amp;amp;#8221; Plus Box&lt;/a&gt; (seroundtable.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.macworld.com/article/143351/2009/10/netprocesses.html?lsrc=rss_main&amp;quot;&amp;gt;See which processes are using the Internet&lt;/a&gt; (macworld.com)&lt;/li&gt; &lt;/ul&gt; &amp;lt;div class=&amp;quot;zemanta-pixie&amp;quot; style=&amp;quot;margin-top: 10px; height: 15px;&amp;quot;&amp;gt;&amp;lt;a class=&amp;quot;zemanta-pixie-a&amp;quot; title=&amp;quot;Reblog this post [with Zemanta]&amp;quot; href=&amp;quot;http://reblog.zemanta.com/zemified/cc60245b-7397-4d48-83b2-7bfb345ae7a9/&amp;quot;&amp;gt;&amp;lt;img class=&amp;quot;zemanta-pixie-img&amp;quot; style=&amp;quot;border: medium none; float: right;&amp;quot; src=&amp;quot;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_e20.png&amp;quot; alt=&amp;quot;Reblog this post [with Zemanta]&amp;quot; /&amp;gt;&lt;/a&gt;&amp;lt;span class=&amp;quot;zem-script more-related pretty-attribution&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
