<?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>Fei Nan</title>
	<atom:link href="http://feinan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://feinan.com</link>
	<description>http://feinan.com</description>
	<lastBuildDate>Thu, 15 Dec 2011 13:43:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calculator with awk</title>
		<link>http://feinan.com/2011/12/15/calculator-with-awk/</link>
		<comments>http://feinan.com/2011/12/15/calculator-with-awk/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 13:41:03 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/12/15/calculator-with-awk/</guid>
		<description><![CDATA[In your bash, do the following

1
calc&#40;&#41;&#123; awk &#34;BEGIN{ print $* }&#34; ; &#125;

and then do the following:

2
calc 2*1 - 12

or

3
calc '2*(1 - 12)'

you can put this in your ~/.bash_profile too
]]></description>
			<content:encoded><![CDATA[<p>In your bash, do the following</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">calc<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;">awk</span> <span style="color: #ff0000;">&quot;BEGIN{ print $* }&quot;</span> ; <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>and then do the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">calc <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">1</span> - <span style="color: #000000;">12</span></pre></td></tr></table></div>

<p>or</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">calc <span style="color: #ff0000;">'2*(1 - 12)'</span></pre></td></tr></table></div>

<p>you can put this in your ~/.bash_profile too</p>
]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/12/15/calculator-with-awk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command &#8211; traceroute</title>
		<link>http://feinan.com/2011/12/09/command-traceroute/</link>
		<comments>http://feinan.com/2011/12/09/command-traceroute/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 02:55:43 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/12/09/command-traceroute/</guid>
		<description><![CDATA[
Traceroute is a command which can show you the path a packet of information takes from your computer to one you specify. It will list all the routers it passes through until it reaches its destination, or fails to and is discarded. In addition to this, it will tell you how long each hop from [...]]]></description>
			<content:encoded><![CDATA[<div class='posterous_autopost'>
<div>Traceroute is a command which can show you the path a packet of information takes from your computer to one you specify. It will list all the routers it passes through until it reaches its destination, or fails to and is discarded. In addition to this, it will tell you how long each hop from router to router takes.<br />
 </div>
<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
20
21
22
23
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>sjc14-esx2-vm3 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># traceroute iph.csi2.c3w.tv</span>
traceroute to iph.csi2.c3w.tv <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.77.180<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">30</span> hops max, <span style="color: #000000;">40</span> byte packets
 <span style="color: #000000;">1</span>  172.29.96.1 <span style="color: #7a0874; font-weight: bold;">&#40;</span>172.29.96.1<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">3.150</span> ms  <span style="color: #000000;">3.141</span> ms  <span style="color: #000000;">3.135</span> ms
 <span style="color: #000000;">2</span>  sjc14-00lab-gw1-gig1-4.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>172.24.114.181<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">3.120</span> ms  <span style="color: #000000;">3.105</span> ms  <span style="color: #000000;">3.094</span> ms
 <span style="color: #000000;">3</span>  sjc12-lab4-gw1-ten6-7.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>172.24.95.29<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">3.086</span> ms  <span style="color: #000000;">3.078</span> ms  <span style="color: #000000;">3.067</span> ms
 <span style="color: #000000;">4</span>  sjc5-sbb4-gw1-ten8-6.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>171.71.241.174<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">3.049</span> ms  <span style="color: #000000;">3.045</span> ms  <span style="color: #000000;">3.037</span> ms
 <span style="color: #000000;">5</span>  sjc12-rbb-gw4-ten7-4.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>171.71.241.254<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">3.003</span> ms  <span style="color: #000000;">2.997</span> ms  <span style="color: #000000;">2.988</span> ms
 <span style="color: #000000;">6</span>  sjc12-gb1-ten2-2.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.4.157<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">2.974</span> ms  <span style="color: #000000;">3.924</span> ms  <span style="color: #000000;">3.914</span> ms
 <span style="color: #000000;">7</span>  capnet-rtp10-sjc12-10ge.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.4.162<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">78.649</span> ms  <span style="color: #000000;">78.646</span> ms  <span style="color: #000000;">79.351</span> ms
 <span style="color: #000000;">8</span>  rtp5-rbb-gw1-ten4-6.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.4.106<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">81.145</span> ms  <span style="color: #000000;">81.143</span> ms  <span style="color: #000000;">81.863</span> ms
 <span style="color: #000000;">9</span>  rtp5-gb2-ten2-1.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.3.77<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">79.921</span> ms  <span style="color: #000000;">79.917</span> ms  <span style="color: #000000;">79.911</span> ms
<span style="color: #000000;">10</span>  capnet-amsidc-rtp5-oc48.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.4.114<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">167.285</span> ms  <span style="color: #000000;">167.277</span> ms  <span style="color: #000000;">167.263</span> ms
<span style="color: #000000;">11</span>  amsidc-rbb-gw2-ten2-1.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.112.4.202<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">167.197</span> ms  <span style="color: #000000;">167.194</span> ms  <span style="color: #000000;">166.839</span> ms
<span style="color: #000000;">12</span>  amsidc-wan-gw1-ten6-2.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>144.254.78.14<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">168.174</span> ms  <span style="color: #000000;">167.671</span> ms  <span style="color: #000000;">167.639</span> ms
<span style="color: #000000;">13</span>  amsidc-cw-pe1-oc48.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>10.61.40.18<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">167.006</span> ms  <span style="color: #000000;">167.087</span> ms  <span style="color: #000000;">167.075</span> ms
<span style="color: #000000;">14</span>  ntn01-wan-gw1-ser1-0.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>144.254.136.193<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">256.178</span> ms  <span style="color: #000000;">256.308</span> ms  <span style="color: #000000;">256.298</span> ms
<span style="color: #000000;">15</span>  ntn01-bb-gw2-gig2-7.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.103.115.205<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">255.074</span> ms  <span style="color: #000000;">254.828</span> ms  <span style="color: #000000;">255.553</span> ms
<span style="color: #000000;">16</span>  ntn01-corp-gw1-gig0-2.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.103.116.14<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">254.310</span> ms  <span style="color: #000000;">254.302</span> ms  <span style="color: #000000;">254.297</span> ms
<span style="color: #000000;">17</span>  ntn01-dmzbb-gw1-gig2-43.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.78.166<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">260.572</span> ms  <span style="color: #000000;">260.568</span> ms  <span style="color: #000000;">257.431</span> ms
<span style="color: #000000;">18</span>  ntn01-dmznet-gw1-gig1-1.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.78.86<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">254.664</span> ms  <span style="color: #000000;">254.664</span> ms  <span style="color: #000000;">254.655</span> ms
<span style="color: #000000;">19</span>  ntn01-dmzlab-gw1-gig1-1.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.76.26<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">256.993</span> ms  <span style="color: #000000;">257.295</span> ms  <span style="color: #000000;">256.258</span> ms
<span style="color: #000000;">20</span>  csi-scp-dmz-gw.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.76.106<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">257.160</span> ms  <span style="color: #000000;">257.138</span> ms  <span style="color: #000000;">256.874</span> ms
<span style="color: #000000;">21</span>  csi-scp-dmz-gw.cisco.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>192.118.76.106<span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #000000;">257.300</span> ms <span style="color: #000000; font-weight: bold;">!</span>X <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span></pre></td></tr></table></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/12/09/command-traceroute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WireShark Filter Example</title>
		<link>http://feinan.com/2011/11/17/wireshark-filter-example/</link>
		<comments>http://feinan.com/2011/11/17/wireshark-filter-example/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 02:50:17 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/11/17/wireshark-filter-example/</guid>
		<description><![CDATA[
1
ip.addr == 172.29.96.30 and http and http.request.method == GET

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">ip.addr == 172.29.96.30 and http and http.request.method == GET</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/11/17/wireshark-filter-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clear DNS Cache on Linux</title>
		<link>http://feinan.com/2011/10/14/clear-dns-cache-on-linux/</link>
		<comments>http://feinan.com/2011/10/14/clear-dns-cache-on-linux/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 01:54:43 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/10/14/clear-dns-cache-on-linux/</guid>
		<description><![CDATA[To Invalidate /etc/hosts cache, aka, clear DNS cache.

1
nscd -i hosts

]]></description>
			<content:encoded><![CDATA[<p>To Invalidate /etc/hosts cache, aka, clear DNS cache.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">nscd <span style="color: #660033;">-i</span> hosts</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/10/14/clear-dns-cache-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing (X)HTML in C – A libxml2 tutorial</title>
		<link>http://feinan.com/2011/09/29/parsing-xhtml-in-c-%e2%80%93-a-libxml2-tutorial/</link>
		<comments>http://feinan.com/2011/09/29/parsing-xhtml-in-c-%e2%80%93-a-libxml2-tutorial/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 23:21:19 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/09/29/parsing-xhtml-in-c-%e2%80%93-a-libxml2-tutorial/</guid>
		<description><![CDATA[Parsing (X)HTML in C is often seen as a difficult task.  It’s true that C isn’t the easiest language to use to develop a parser.  Fortunately, libxml2&#8217;s HTMLParser module come to the rescue.  So, as promised, here’s a small tutorial explaining how to use libxml2&#8217;s HTMLParser to parse (X)HTML.
First, you need to create a parser [...]]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">Parsing (X)HTML in C is often seen as a difficult task.  It’s true that C isn’t the easiest language to use to develop a parser.  Fortunately, libxml2&#8217;s HTMLParser module come to the rescue.  So, as promised, here’s a small tutorial explaining how to use libxml2&#8217;s HTMLParser to parse (X)HTML.<br />
First, you need to create a parser context.  You have many functions for doing that, depending on how you want to feed data to the parser.  I’ll use htmlCreatePushParserCtxt(), since it work with memory buffers.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">htmlParserCtxtPtr parser <span style="color: #339933;">=</span> htmlCreatePushParserCtxt<span style="color: #009900;">&#40;</span>NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Then, you can set many options on that parser context.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">htmlCtxtUseOptions<span style="color: #009900;">&#40;</span>parser<span style="color: #339933;">,</span> HTML_PARSE_NOBLANKS <span style="color: #339933;">|</span> HTML_PARSE_NOERROR <span style="color: #339933;">|</span> HTML_PARSE_NOWARNING <span style="color: #339933;">|</span> HTML_PARSE_NONET<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>We are now ready to parse an (X)HTML document.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>3
4
5
6
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// char * data : buffer containing part of the web page</span>
<span style="color: #666666; font-style: italic;">// int len : number of bytes in data</span>
<span style="color: #666666; font-style: italic;">// Last argument is 0 if the web page isn’t complete, and 1 for the final call.</span>
htmlParseChunk<span style="color: #009900;">&#40;</span>parser<span style="color: #339933;">,</span> data<span style="color: #339933;">,</span> len<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Once you’ve pushed it all your data, you can call that function again with a NULL buffer and ’1&#8242; as the last argument.  This will ensure that the parser have processed everything.</p>
<p>Finally, how to get the data you parsed?  That’s easier than it seems.  You simply have to walk the XML tree created.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> walkTree<span style="color: #009900;">&#40;</span>xmlNode <span style="color: #339933;">*</span> a_node<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  xmlNode <span style="color: #339933;">*</span>cur_node <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  xmlAttr <span style="color: #339933;">*</span>cur_attr <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>cur_node <span style="color: #339933;">=</span> a_node<span style="color: #339933;">;</span> cur_node<span style="color: #339933;">;</span> cur_node <span style="color: #339933;">=</span> cur_node<span style="color: #339933;">-&gt;</span>next<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// do something with that node information, like… printing the tag’s name and attributes</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span>“Got tag <span style="color: #339933;">:</span> <span style="color: #339933;">%</span>s\n”<span style="color: #339933;">,</span> cur_node<span style="color: #339933;">-&gt;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>cur_attr <span style="color: #339933;">=</span> cur_node<span style="color: #339933;">-&gt;</span>properties<span style="color: #339933;">;</span> cur_attr<span style="color: #339933;">;</span> cur_attr <span style="color: #339933;">=</span> cur_attr<span style="color: #339933;">-&gt;</span>next<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span>“  <span style="color: #339933;">-&gt;</span> with attribute <span style="color: #339933;">:</span> <span style="color: #339933;">%</span>s\n”<span style="color: #339933;">,</span> cur_attre<span style="color: #339933;">-&gt;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    walkTree<span style="color: #009900;">&#40;</span>cur_node<span style="color: #339933;">-&gt;</span>children<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
walkTree<span style="color: #009900;">&#40;</span>xmlDocGetRootElement<span style="color: #009900;">&#40;</span>parser<span style="color: #339933;">-&gt;</span>myDoc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And that’s it!  Isn’t that simple enough?  From there, you can do any kind of stuff, like finding all referenced images (by looking at “img” tag) and fetching them, or anything you can think of doing.</p>
<p>Also, you should know that you can walk the XML tree anytime, even if you haven’t parsed the whole (X)HTML document yet.</p>
<p>If you have to parse (X)HTML in C, you should use libxml2&#8217;s HTMLParser.  It will save you a lot of time.</p>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via email</a> from <a href="http://feinan.posterous.com/parsing-xhtml-in-c-a-libxml2-tutorial">feinan&#8217;s posterous</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/09/29/parsing-xhtml-in-c-%e2%80%93-a-libxml2-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print All Emails in Web Pages</title>
		<link>http://feinan.com/2011/09/11/print-all-emails-in-web-pages/</link>
		<comments>http://feinan.com/2011/09/11/print-all-emails-in-web-pages/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 21:36:30 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/09/11/print-all-emails-in-web-pages/</guid>
		<description><![CDATA[
1
2
3
4
5
#!/bin/bash
for &#40;&#40;i=1;i&#60;=20;i++&#41;&#41;
do
  wget -q -O - http://www.mitbbs.com/article_t1/Immigration/31933935_0_$i.html &#124; grep -o '[[:alnum:]+\.\_\-][[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*[[:alnum:]+]' &#124; sort &#124; uniq
done

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">i</span>=<span style="color: #000000;">1</span>;i<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000;">20</span>;i++<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - http:<span style="color: #000000; font-weight: bold;">//</span>www.mitbbs.com<span style="color: #000000; font-weight: bold;">/</span>article_t1<span style="color: #000000; font-weight: bold;">/</span>Immigration<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">31933935</span>_0_<span style="color: #007800;">$i</span>.html <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'[[:alnum:]+\.\_\-][[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*[[:alnum:]+]'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/09/11/print-all-emails-in-web-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort File by Given Column</title>
		<link>http://feinan.com/2011/04/05/sort-file-by-given-column/</link>
		<comments>http://feinan.com/2011/04/05/sort-file-by-given-column/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 19:43:01 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/04/05/sort-file-by-given-column/</guid>
		<description><![CDATA[
1
2
3
4
5
6
7
8
sort -r +2 -3 infile
+m Start at the first character of the m+1th field.
-n End at the last character of the nth field &#40;if -N omitted, assume the end of the line&#41;.
-f Make all lines uppercase before sorting &#40;so &#34;Bill&#34; and &#34;bill&#34; are treated the same&#41;.
-r Sort in reverse order &#40;so &#34;Z&#34; starts the list [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</span> +<span style="color: #000000;">2</span> <span style="color: #660033;">-3</span> infile
+m Start at the first character of the m+1th field.
<span style="color: #660033;">-n</span> End at the <span style="color: #c20cb9; font-weight: bold;">last</span> character of the nth field <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #660033;">-N</span> omitted, assume the end of the line<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
<span style="color: #660033;">-f</span> Make all lines uppercase before sorting <span style="color: #7a0874; font-weight: bold;">&#40;</span>so <span style="color: #ff0000;">&quot;Bill&quot;</span> and <span style="color: #ff0000;">&quot;bill&quot;</span> are treated the same<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
<span style="color: #660033;">-r</span> Sort <span style="color: #000000; font-weight: bold;">in</span> reverse order <span style="color: #7a0874; font-weight: bold;">&#40;</span>so <span style="color: #ff0000;">&quot;Z&quot;</span> starts the list instead of <span style="color: #ff0000;">&quot;A&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.
<span style="color: #660033;">-n</span> Sort a column <span style="color: #000000; font-weight: bold;">in</span> numerical order
<span style="color: #660033;">-tx</span> Use x <span style="color: #c20cb9; font-weight: bold;">as</span> the field delimiter <span style="color: #7a0874; font-weight: bold;">&#40;</span>replace x with a comma or other character<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
<span style="color: #660033;">-u</span> Suppress all but one line <span style="color: #000000; font-weight: bold;">in</span> each <span style="color: #000000; font-weight: bold;">set</span> of lines with equal <span style="color: #c20cb9; font-weight: bold;">sort</span> fields <span style="color: #7a0874; font-weight: bold;">&#40;</span>so <span style="color: #000000; font-weight: bold;">if</span> you <span style="color: #c20cb9; font-weight: bold;">sort</span> on a field containing <span style="color: #c20cb9; font-weight: bold;">last</span> names, only one <span style="color: #ff0000;">&quot;Smith&quot;</span> will appear even <span style="color: #000000; font-weight: bold;">if</span> there are several<span style="color: #7a0874; font-weight: bold;">&#41;</span>.</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/04/05/sort-file-by-given-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print Even Lines in a File</title>
		<link>http://feinan.com/2011/04/05/print-even-lines-in-a-file/</link>
		<comments>http://feinan.com/2011/04/05/print-even-lines-in-a-file/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 19:38:40 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/04/05/print-even-lines-in-a-file/</guid>
		<description><![CDATA[
1
awk 'NR%2==0' infile

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'NR%2==0'</span> infile</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/04/05/print-even-lines-in-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursively untar all zip in directory</title>
		<link>http://feinan.com/2011/03/15/recursively-untar-all-zip-in-directory/</link>
		<comments>http://feinan.com/2011/03/15/recursively-untar-all-zip-in-directory/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 01:42:01 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/03/15/recursively-untar-all-zip-in-directory/</guid>
		<description><![CDATA[
1
for i in `ls *.tgz`; do  tar zxvf $i; done

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">*</span>.tgz<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>  <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/03/15/recursively-untar-all-zip-in-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List Word Occurrence for A Given Document</title>
		<link>http://feinan.com/2011/02/16/list-word-occurrence-for-a-given-document-2/</link>
		<comments>http://feinan.com/2011/02/16/list-word-occurrence-for-a-given-document-2/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 02:41:30 +0000</pubDate>
		<dc:creator>feinan</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://feinan.com/2011/02/16/list-word-occurrence-for-a-given-document-2/</guid>
		<description><![CDATA[
1
2
3
4
5
6
7
8
9
10
11
12
cat nautilus-debug-log.txt &#124; tr -cs A-Za-z '\012' &#124; tr A-Z a-z &#124; sort &#124; uniq -c &#124; sort -r -n &#124; sed 25q
  2660 x
  2659 user
  2659 to
  2659 signal
  2659 log
  2659 dumped
  2659 due
  2659 debug
     1 milestones
   [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> nautilus-debug-log.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-cs</span> A-Za-z <span style="color: #ff0000;">'\012'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> A-Z a-z <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> 25q
  <span style="color: #000000;">2660</span> x
  <span style="color: #000000;">2659</span> user
  <span style="color: #000000;">2659</span> to
  <span style="color: #000000;">2659</span> signal
  <span style="color: #000000;">2659</span> log
  <span style="color: #000000;">2659</span> dumped
  <span style="color: #000000;">2659</span> due
  <span style="color: #000000;">2659</span> debug
     <span style="color: #000000;">1</span> milestones
     <span style="color: #000000;">1</span> begin
     <span style="color: #000000;">1</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://feinan.com/2011/02/16/list-word-occurrence-for-a-given-document-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

