<?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>Cai Feng's Blog &#187; shell</title>
	<atom:link href="http://blog.caifeng.me/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.caifeng.me</link>
	<description>Paw trace ...</description>
	<lastBuildDate>Tue, 19 Oct 2010 16:53:31 +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>分析日志常用到的几个shell工具</title>
		<link>http://blog.caifeng.me/2009/03/31/%e5%88%86%e6%9e%90%e6%97%a5%e5%bf%97%e5%b8%b8%e7%94%a8%e5%88%b0%e7%9a%84%e5%87%a0%e4%b8%aashell%e5%b7%a5%e5%85%b7/</link>
		<comments>http://blog.caifeng.me/2009/03/31/%e5%88%86%e6%9e%90%e6%97%a5%e5%bf%97%e5%b8%b8%e7%94%a8%e5%88%b0%e7%9a%84%e5%87%a0%e4%b8%aashell%e5%b7%a5%e5%85%b7/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 03:03:40 +0000</pubDate>
		<dc:creator>ljpsfree</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.caifeng.me/blog/2009/03/31/%e5%88%86%e6%9e%90%e6%97%a5%e5%bf%97%e5%b8%b8%e7%94%a8%e5%88%b0%e7%9a%84%e5%87%a0%e4%b8%aashell%e5%b7%a5%e5%85%b7/</guid>
		<description><![CDATA[一个不错的例子: http://nunojob.wordpress.com/2008/04/12/history-awk-print-2-sort-uniq-c-sort-rn-head/

httpd.log &#124; awk '{print $2}' \  &#124; sort &#124; uniq -c &#124; sort -rn &#124; head

解释:
httpd.log : 要分析的日志
awk : 用来取出某一特定的列。简单的也可以用cut来代替
sort : 用来排序(第一次排序是用来为后面的uniq服务的。uniq对于没有排序的内容工作不正确)
uniq : 用来uniq有序的内容，-c参数会把重复次数带上
sort -rn : 用来安重复次数倒序排列
head : 用来去前几条数据，默认是10.
]]></description>
			<content:encoded><![CDATA[<p>一个不错的例子: http://nunojob.wordpress.com/2008/04/12/history-awk-print-2-sort-uniq-c-sort-rn-head/</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">httpd.log <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</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: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-rn</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span></pre></div></div>

<p>解释:<br />
httpd.log : 要分析的日志<br />
awk : 用来取出某一特定的列。简单的也可以用cut来代替<br />
sort : 用来排序(第一次排序是用来为后面的uniq服务的。uniq对于没有排序的内容工作不正确)<br />
uniq : 用来uniq有序的内容，-c参数会把重复次数带上<br />
sort -rn : 用来安重复次数倒序排列<br />
head : 用来去前几条数据，默认是10.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.caifeng.me/2009/03/31/%e5%88%86%e6%9e%90%e6%97%a5%e5%bf%97%e5%b8%b8%e7%94%a8%e5%88%b0%e7%9a%84%e5%87%a0%e4%b8%aashell%e5%b7%a5%e5%85%b7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

