<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vidul Nikolaev Petrov &#187; bash</title>
	<atom:link href="http://www.vidul.com/category/administration/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vidul.com</link>
	<description>my web space</description>
	<lastBuildDate>Fri, 09 Apr 2010 21:01:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delete All Directories Except</title>
		<link>http://www.vidul.com/2010/03/27/delete-all-directories-except/</link>
		<comments>http://www.vidul.com/2010/03/27/delete-all-directories-except/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 00:20:04 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[SA]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[except]]></category>

		<guid isPermaLink="false">http://www.vidul.com/?p=647</guid>
		<description><![CDATA[Write a Bash function or an alias.

#######
### alias 
#######
alias _rm_except=&#34;rm -rf $(ls &#124; grep -v ^$1$)&#34;
&#160;
##########
### function
##########
_rm_except &#40;&#41; &#123; rm -rf $&#40;ls &#124; grep -v ^$1$&#41; &#125;
&#160;
# sample usage:
$ cd /tmp &#38;&#38; mkdir 1 2 3 11 22 33
$ _rm_except 1; ls
11  2  22  3  33






		
			Share this on Blinklist
		
		
			Share this on [...]]]></description>
			<content:encoded><![CDATA[<p>Write a <a title="Advanced Bash-Scripting Guide" href="http://tldp.org/LDP/abs/html/" target="_blank">Bash</a> function or an alias.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:arial,verdana,monospace;"><span style="color: #666666; font-style: italic;">#######</span>
<span style="color: #666666; font-style: italic;">### alias </span>
<span style="color: #666666; font-style: italic;">#######</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">_rm_except</span>=<span style="color: #ff0000;">&quot;rm -rf <span style="color: #007800;">$(ls | grep -v ^$1$)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##########</span>
<span style="color: #666666; font-style: italic;">### function</span>
<span style="color: #666666; font-style: italic;">##########</span>
_rm_except <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> ^$<span style="color: #000000;">1</span>$<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># sample usage:</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">11</span> <span style="color: #000000;">22</span> <span style="color: #000000;">33</span>
$ _rm_except <span style="color: #000000;">1</span>; <span style="color: #c20cb9; font-weight: bold;">ls</span>
<span style="color: #000000;">11</span>  <span style="color: #000000;">2</span>  <span style="color: #000000;">22</span>  <span style="color: #000000;">3</span>  <span style="color: #000000;">33</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;Title=Delete+All+Directories+Except+" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;title=Delete+All+Directories+Except+" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;title=Delete+All+Directories+Except+" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;title=Delete+All+Directories+Except+" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;title=Delete+All+Directories+Except+" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2010/03/27/delete-all-directories-except/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Delete+All+Directories+Except++-+http://b2l.me/mbefc+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2010/03/27/delete-all-directories-except/&amp;h=Delete+All+Directories+Except+" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2010/03/27/delete-all-directories-except/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>`mkdir` and `cd` at once</title>
		<link>http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/</link>
		<comments>http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 10:50:39 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[SA]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://www.vidul.com/?p=525</guid>
		<description><![CDATA[I am sick of mkdir dir_name; cd dir_name;
The solution (put this function in &#8220;.bashrc&#8221; or whatever shell config file you use):

_mkcd &#40;&#41; &#123;
       mkdir -p $1
       cd $1
&#125;
# usage: _mkcd /tmp/dir_1/dir_2
# pwd will show: /tmp/dir_1/dir_2






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this [...]]]></description>
			<content:encoded><![CDATA[<p>I am sick of <em>mkdir dir_name; cd dir_name;</em><br />
The solution (put this function in &#8220;.bashrc&#8221; or whatever shell config file you use):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:arial,verdana,monospace;">_mkcd <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
       <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> $<span style="color: #000000;">1</span>
       <span style="color: #7a0874; font-weight: bold;">cd</span> $<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;"># usage: _mkcd /tmp/dir_1/dir_2</span>
<span style="color: #666666; font-style: italic;"># pwd will show: /tmp/dir_1/dir_2</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;Title=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;title=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;title=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;title=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;title=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=%60mkdir%60+and+%60cd%60+at+once+-+http://b2l.me/bndfn+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/&amp;h=%60mkdir%60+and+%60cd%60+at+once" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2009/12/16/mkdir-and-cd-simultaneously/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>unarchive files</title>
		<link>http://www.vidul.com/2009/12/14/unarchive-files/</link>
		<comments>http://www.vidul.com/2009/12/14/unarchive-files/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 19:31:21 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[SA]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[archive]]></category>

		<guid isPermaLink="false">http://www.vidul.com/?p=510</guid>
		<description><![CDATA[a sample BASH function (usually resides in $HOMES/.bashrc)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extract &#40;&#41; &#123;
        if &#91; -f $1 &#93; ; then
                case $1 in
              [...]]]></description>
			<content:encoded><![CDATA[<p><code>a sample <a href="http://en.wikipedia.org/wiki/Bash">BASH</a> function (usually resides in $HOMES/.bashrc)</code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="bash" style="font-family:arial,verdana,monospace;">extract <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #000000; font-weight: bold;">case</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">in</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.tar.bz2<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xjf $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.tar.gz<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.bz2<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">bunzip2</span> $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.rar<span style="color: #7a0874; font-weight: bold;">&#41;</span> rar x $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.gz<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">gunzip</span> $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.tar<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xf $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.tbz2<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xjf $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.tgz<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.zip<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">unzip</span> $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span>.Z<span style="color: #7a0874; font-weight: bold;">&#41;</span> uncompress $<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;'$1' cannot be extracted via extract()&quot;</span><span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000; font-weight: bold;">esac</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;'$1' is not a valid file&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2009/12/14/unarchive-files/&amp;Title=unarchive+files" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2009/12/14/unarchive-files/&amp;title=unarchive+files" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2009/12/14/unarchive-files/&amp;title=unarchive+files" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2009/12/14/unarchive-files/&amp;title=unarchive+files" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2009/12/14/unarchive-files/&amp;title=unarchive+files" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2009/12/14/unarchive-files/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=unarchive+files+-+http://b2l.me/bj24d+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2009/12/14/unarchive-files/&amp;h=unarchive+files" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2009/12/14/unarchive-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>how to monitor ip addresses from a log file</title>
		<link>http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/</link>
		<comments>http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 00:12:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[address]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
tail -f production.log  &#124; egrep &#34;([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}&#34;






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:arial,verdana,monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> production.log  <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}&quot;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;Title=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;title=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;title=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;title=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;title=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=how+to+monitor+ip+addresses+from+a+log+file+-+http://b2l.me/bncw2+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/&amp;h=how+to+monitor+ip+addresses+from+a+log+file" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2009/01/28/how-to-monitor-ip-addresses-from-a-log-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyday UNIX Commands</title>
		<link>http://www.vidul.com/2007/08/23/everyday-unix-commands/</link>
		<comments>http://www.vidul.com/2007/08/23/everyday-unix-commands/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 16:23:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[SA]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[find
Recursively find and print all files, having &#8216;txt&#8217; extention:
find ./ -type f -name "*.txt"

The same but case insensititve:
find ./ -type f -iname "*.txt"
cat all found &#8216;txt&#8217; files:
find ./ -type f -name "*.txt" -exec cat '{}' \;
rm all found &#8216;txt&#8217; files, starting with capital letter:
find ./ -type f -name "[A-Z]*.txt" -exec rm '{}' \;

rm all except [...]]]></description>
			<content:encoded><![CDATA[<p><strong>find</strong><br />
Recursively find and print all files, having &#8216;txt&#8217; extention:<br />
<code>find ./ -type f -name "*.txt"<br />
</code><br />
The same but case insensititve:<br />
<code>find ./ -type f -iname "*.txt"</code></p>
<p>cat all found &#8216;txt&#8217; files:<br />
<code>find ./ -type f -name "*.txt" -exec cat '{}' \;</code></p>
<p>rm all found &#8216;txt&#8217; files, starting with capital letter:<br />
<code>find ./ -type f -name "[A-Z]*.txt" -exec rm '{}' \;<br />
</code><br />
rm all except &#8216;txt&#8217; files:<br />
<code>find ./ -type f ! -name "*.txt" -exec rm '{}' \;</code></p>
<p><strong>grep</strong><br />
Find and print all lines in all files, containing  &#8216;tester&#8217;:<br />
<code>grep tester *</code></p>
<p>Find and print all lines of all files, which do not contain  &#8216;tester&#8217;:<br />
<code>grep -v tester *</code></p>
<p>The same but recursively:<br />
<code>grep -r -v tester *</code></p>
<p>The same but case insensitive:<br />
<code>grep -i -v tester *</code></p>
<p>The same but coloured:<br />
<code>grep -n -r --color=auto -v tester *</code></p>
<p><strong>processes</strong><br />
simple Perl daemon:<br />
<code>perl -e 'use POSIX qw(setsid); fork; setsid; sleep 1, print $c++,$/ while 1'</code></p>
<p>checking the process existance: <code>ps x | perl</code></p>
<p>another way to find the process id: <code>pgrep perl</code></p>
<p>kill all processes, related to perl interpreter:<code>pkill perl</code></p>
<p>monitor all processes within 1 second interval:<code>top -d1</code></p>
<p>monitor all processes, which access the storage devices:<code>iotop -d1</code></p>
<p>monitor all open files (pipes, sockets, directories, etc.):<code>lsof</code></p>
<p><strong>archive</strong><br />
Archive directory and all files and sub-directories:<br />
<code>tar cvf home.tar /home</code></p>
<p>The same but gzip compresses:<br />
<code>tar zcvf home.tar.gz /home</code></p>
<p>The same but bzip2 compressed:<br />
<code>tar jcvf home.tar.bz2 /home</code></p>
<p>&#8220;untar&#8221; gzip compressed archive:<br />
<code>tar zxvf home.tar.gz</code></p>
<p>&#8220;untar&#8221; bzip2 compressed archive:<br />
<code>tar jxvf home.tar.gz</code></p>
<p>column extraction, assuming, that all user names are needed &#8220;/etc/passwd&#8221;:</p>
<p>cut command<br />
<code>cat /etc/passwd | cut -f1 -d:</code></p>
<p>awk script<br />
<code>cat /etc/passwd | awk -F':' '{print $1}'</code></p>
<p>Perl source code<br />
<code>perl -ne '/(\w+)/ &#038;&#038; print $1,$/' /etc/passwd</code></p>
<p>Ruby source code<br />
<code>ruby -ne 'puts $1 if /(\w+)/' /etc/passwd</code></p>
<p>ISO image manipulation</p>
<p>ISO image creation:<br />
<code>dd if=/dev/cdrom of=/tmp/cdr.iso<br />
mkisofs -rJTV "books label" /home/books > /tmp/books.iso</code></p>
<p>ISO image reading:<br />
<code>mount -o loop -t iso9660 /tmp/books.iso /mnt/isoimage</code></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;Title=Everyday+UNIX+Commands" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;title=Everyday+UNIX+Commands" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;title=Everyday+UNIX+Commands" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;title=Everyday+UNIX+Commands" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;title=Everyday+UNIX+Commands" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2007/08/23/everyday-unix-commands/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Everyday+UNIX+Commands+-+http://b2l.me/bmqez+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2007/08/23/everyday-unix-commands/&amp;h=Everyday+UNIX+Commands" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2007/08/23/everyday-unix-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
