<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic parse help needed in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266089#M11872</link>
    <description>Hi all, &lt;BR /&gt;I have a router log file that I would like to parse. It contains 4 columns of IP's. I would like to sort them based on column 4, and also add a number to each row of how many occurances of that particular connection. &lt;BR /&gt;i.e&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.20  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;...&lt;BR /&gt;so there is one connection from 10.12.5.20 and 3 from 10.12.5.24, so the output would be &lt;BR /&gt;&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5    3&lt;BR /&gt;10.12.5.20  172.10.5.10  172.10.5.12   172.50.101.5    1&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I started with an awk script, something like:&lt;BR /&gt;cat filename.txt | awk '{print $4" "$3" "$2" "$1} | sort | uniq&lt;BR /&gt;&lt;BR /&gt;but it didn't look quite right, and I couldn't figure out how to generate the number of occurances, and my perl knowledge is about useless :( &lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated, and if more info is needed, let me know&lt;BR /&gt;&lt;BR /&gt;Thanks! &lt;BR /&gt;&lt;BR /&gt;CH</description>
    <pubDate>Mon, 03 May 2004 15:17:15 GMT</pubDate>
    <dc:creator>Chris H_3</dc:creator>
    <dc:date>2004-05-03T15:17:15Z</dc:date>
    <item>
      <title>parse help needed</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266089#M11872</link>
      <description>Hi all, &lt;BR /&gt;I have a router log file that I would like to parse. It contains 4 columns of IP's. I would like to sort them based on column 4, and also add a number to each row of how many occurances of that particular connection. &lt;BR /&gt;i.e&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.20  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5&lt;BR /&gt;...&lt;BR /&gt;so there is one connection from 10.12.5.20 and 3 from 10.12.5.24, so the output would be &lt;BR /&gt;&lt;BR /&gt;10.12.5.24  172.10.5.10  172.10.5.12   172.50.101.5    3&lt;BR /&gt;10.12.5.20  172.10.5.10  172.10.5.12   172.50.101.5    1&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I started with an awk script, something like:&lt;BR /&gt;cat filename.txt | awk '{print $4" "$3" "$2" "$1} | sort | uniq&lt;BR /&gt;&lt;BR /&gt;but it didn't look quite right, and I couldn't figure out how to generate the number of occurances, and my perl knowledge is about useless :( &lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated, and if more info is needed, let me know&lt;BR /&gt;&lt;BR /&gt;Thanks! &lt;BR /&gt;&lt;BR /&gt;CH</description>
      <pubDate>Mon, 03 May 2004 15:17:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266089#M11872</guid>
      <dc:creator>Chris H_3</dc:creator>
      <dc:date>2004-05-03T15:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: parse help needed</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266090#M11873</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;maybe not the greatest, but should do the trick :-)&lt;BR /&gt;&lt;BR /&gt;$file = "temp.txt";&lt;BR /&gt;&lt;BR /&gt;open(IN, $file);&lt;BR /&gt;while(&lt;IN&gt;){&lt;BR /&gt; chomp();&lt;BR /&gt; @words = split();&lt;BR /&gt; $srec = join(" ", $words[3], $words[0], $words[1], $words[2]);&lt;BR /&gt; $sarr{$srec} = $_;&lt;BR /&gt; $count{$_}++;&lt;BR /&gt;}&lt;BR /&gt;close(IN);&lt;BR /&gt;&lt;BR /&gt;foreach $key (sort keys %sarr){&lt;BR /&gt;  printf "%s %s\n", $sarr{$key}, $count{$sarr{$key}};&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Hopefully ITRC does not mess this up completely.&lt;BR /&gt;&lt;BR /&gt;Greetings, Martin&lt;/IN&gt;</description>
      <pubDate>Mon, 03 May 2004 16:29:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266090#M11873</guid>
      <dc:creator>Martin P.J. Zinser</dc:creator>
      <dc:date>2004-05-03T16:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: parse help needed</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266091#M11874</link>
      <description>Hi CH,&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;sort +4 -5 filename.txt | uniq -c | sort -r&lt;BR /&gt;&lt;BR /&gt;and if you need the counter first:&lt;BR /&gt;&lt;BR /&gt;sort +4 -5 filename.txt | uniq -c | sort -r | awk '{printf $2" "$3" "$4" "$5" "$1"\n"}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Frank.</description>
      <pubDate>Mon, 03 May 2004 16:37:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266091#M11874</guid>
      <dc:creator>Francisco J. Soler</dc:creator>
      <dc:date>2004-05-03T16:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: parse help needed</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266092#M11875</link>
      <description>Oooo, that sort is slick, thanks Frank. &lt;BR /&gt;&lt;BR /&gt;Actually, they both did the trick, so thank you both. Cool to see it from two ways. &lt;BR /&gt;&lt;BR /&gt;Thanks again! &lt;BR /&gt;&lt;BR /&gt;CH</description>
      <pubDate>Mon, 03 May 2004 17:47:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parse-help-needed/m-p/3266092#M11875</guid>
      <dc:creator>Chris H_3</dc:creator>
      <dc:date>2004-05-03T17:47:29Z</dc:date>
    </item>
  </channel>
</rss>

