<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: awk code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 29 Aug 2008 02:43:20 GMT</pubDate>
    <description>DZone Snippets: awk code</description>
    <item>
      <title>Cut some text from file</title>
      <link>http://snippets.dzone.com/posts/show/5995</link>
      <description>// 1234567@2345|[HELLO]|adcbdefhij: asgdfdasdfhhfd-asdfasd-dsfasdf |0.678|0.0|0.213&lt;br /&gt;// 1234567@2345|[HELLO]|adcbdefhij: ashhfd-asdfasd-dsfasdf |0.129|0.0|0.411&lt;br /&gt;// 1234567@2345|[HELLO]|adcbdefhij: asd-aasd-dasdf |0.223|0.0|0.276&lt;br /&gt;// delete the text which occurs between @ and :&lt;br /&gt;// remove the numbers which occur at the end of every line |0.223|0.0|0.276&lt;br /&gt;&lt;code&gt;&lt;br /&gt;awk 'BEGIN{FS="[@:|]"}{ printf "%s%s\n",$1,$5}' file&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 07:46:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5995</guid>
      <author>shantanuo (shantanu oak)</author>
    </item>
    <item>
      <title>extract table names from sql log file</title>
      <link>http://snippets.dzone.com/posts/show/4639</link>
      <description>&lt;code&gt;&lt;br /&gt;grep "from " /var/log/mysql/mysqld.log | awk -Ffrom '{print $2}' | awk '{print $1}' | cat &gt; /home/shantanu/testing.txt&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 12 Oct 2007 08:23:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4639</guid>
      <author>shantanuo (shantanu oak)</author>
    </item>
    <item>
      <title>Parse Exim log file with SpamAssassin score</title>
      <link>http://snippets.dzone.com/posts/show/4590</link>
      <description>&lt;code&gt;&lt;br /&gt;grep '\[Spam score: [1-9]' /var/log/exim/main.log | awk '{print $3}' | xargs -t -i grep {} /var/log/exim/main.log &gt; /var/log/exim/spam_score.log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;grep 'reporter\.pl' /var/log/exim/main.log | awk '{print $3}' | xargs -t -i grep {} /var/log/exim/main.log &gt; /var/log/exim/spam_reporter.pl.log&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 29 Sep 2007 08:50:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4590</guid>
      <author>Wallace (Wallace)</author>
    </item>
    <item>
      <title>FInd slow actions in a Rails app</title>
      <link>http://snippets.dzone.com/posts/show/4440</link>
      <description>&lt;code&gt;&lt;br /&gt;# Show a list of actions sorted by time taken. Useful for finding slow actions.&lt;br /&gt;cat log/development.log | awk '/Completed/ { print "[" $3 "] - " $0 }' | sort -nr&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 21 Aug 2007 21:08:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4440</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>See your most used shell commands</title>
      <link>http://snippets.dzone.com/posts/show/4240</link>
      <description>Found &lt;a href="http://lifehacker.com/software/how-to/turbocharge-your-terminal-274317.php"&gt;here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 03 Jul 2007 01:39:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4240</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
    <item>
      <title>MySQL Database Size</title>
      <link>http://snippets.dzone.com/posts/show/4117</link>
      <description>&lt;code&gt;mysql -uroot -D sfcnet_development -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'&lt;/code&gt;</description>
      <pubDate>Fri, 08 Jun 2007 14:51:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4117</guid>
      <author>willcodeforfoo ()</author>
    </item>
    <item>
      <title>HTML Table to CSV in AWK</title>
      <link>http://snippets.dzone.com/posts/show/3848</link>
      <description>Here's a simple AWK script to try to parse an HTML table into a comma seperated file&lt;br /&gt;from &lt;a href="http://euri.ca/blog/category/awk/"&gt;http://euri.ca/blog/category/awk/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;BEGIN {s=""; FS="n"}&lt;br /&gt;/&lt;td/ { gsub(/&lt;[^&gt;]*&gt;/, ""); s=(s ", " $1);}&lt;br /&gt;/&lt;tr|&lt;TR/ { print s; s="" }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And then you execute it (on windows) as: gawk -f 1.awk *.jsp &gt; whatever.csv</description>
      <pubDate>Sat, 21 Apr 2007 03:25:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3848</guid>
      <author>jivechicken (Dave)</author>
    </item>
    <item>
      <title>Sort file by length of lines</title>
      <link>http://snippets.dzone.com/posts/show/3280</link>
      <description>Sort file by length of lines&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cat $@ | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 14 Jan 2007 03:41:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3280</guid>
      <author>AlpT (AlpT)</author>
    </item>
    <item>
      <title>processing columns</title>
      <link>http://snippets.dzone.com/posts/show/2683</link>
      <description>print the first column, delimited by space &lt;br /&gt;&lt;code&gt;&lt;br /&gt;nawk -Fc '{print $1}' test.txt&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;print the second column, delimited by : &lt;br /&gt;&lt;code&gt;&lt;br /&gt;nawk -F: '{print $2}' test.txt&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Sat, 23 Sep 2006 17:57:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2683</guid>
      <author>nevadalife (nevada)</author>
    </item>
    <item>
      <title>OSX Restart Lookupd</title>
      <link>http://snippets.dzone.com/posts/show/2636</link>
      <description>sudo kill -HUP `ps -ax | grep lookupd | grep sbin | awk '/(\d+).*/ { print $1 }'`</description>
      <pubDate>Fri, 22 Sep 2006 00:59:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2636</guid>
      <author>phlipper (Phil Cohen)</author>
    </item>
  </channel>
</rss>
