<?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 Re: Pull data from file with script tool? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089237#M92227</link>
    <description>&lt;!--!*#--&gt;Try the awk construct below. It does what you are looking for:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;  x[$2]++&lt;BR /&gt;  if (f[$2]) {&lt;BR /&gt;    if ($0!=f[$2]) f[$2]=f[$2]"\n"$0&lt;BR /&gt;    else delete f[$2]&lt;BR /&gt;  } else f[$2]=$0&lt;BR /&gt;} END {for (i in f) if (x[i]&amp;gt;1) print f[i]}' file</description>
    <pubDate>Sat, 20 Oct 2007 12:44:26 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2007-10-20T12:44:26Z</dc:date>
    <item>
      <title>Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089231#M92221</link>
      <description>If I have a file like this:&lt;BR /&gt;&lt;BR /&gt;123  789&lt;BR /&gt;234  500&lt;BR /&gt;999  662&lt;BR /&gt;373  881&lt;BR /&gt;474  662&lt;BR /&gt;611  200&lt;BR /&gt;515  789&lt;BR /&gt;809  424&lt;BR /&gt;234  500&lt;BR /&gt;&lt;BR /&gt;I want to return each row that has a value in field two that appears with one or more different values in field one.  So from this list, I want:&lt;BR /&gt;&lt;BR /&gt;999  662&lt;BR /&gt;474  662&lt;BR /&gt;123  789&lt;BR /&gt;515  789&lt;BR /&gt;&lt;BR /&gt;I do not want:&lt;BR /&gt;&lt;BR /&gt;234  500&lt;BR /&gt;234  500&lt;BR /&gt;&lt;BR /&gt;because that value matches.  I want to see when a value repeats in field two with a different value in field one.  Make sense?&lt;BR /&gt;&lt;BR /&gt;I'm sure some awk or perl expert can knock this one out quick.  Thanks for the help in advance!</description>
      <pubDate>Fri, 19 Oct 2007 21:03:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089231#M92221</guid>
      <dc:creator>TDW</dc:creator>
      <dc:date>2007-10-19T21:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089232#M92222</link>
      <description>What needs to happen with a 3rd value pair?&lt;BR /&gt;- when the first pairs where the same "432 500"&lt;BR /&gt;- when they were not "456 789"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is one way:&lt;BR /&gt;&lt;BR /&gt;perl -n x.pl x&lt;BR /&gt;--- x.pl ---&lt;BR /&gt;($left,$right)=split;&lt;BR /&gt;$prior = $seen{$right};&lt;BR /&gt;if (defined $prior) {&lt;BR /&gt;   if ($left ne $prior) {&lt;BR /&gt;      print "$prior $right\n$left $right\n";&lt;BR /&gt;      delete $seen{$right}&lt;BR /&gt;      }&lt;BR /&gt;   } else {&lt;BR /&gt;   $seen{$right} = $left;&lt;BR /&gt;   }&lt;BR /&gt;-------------&lt;BR /&gt;&lt;BR /&gt;So this tosses ignores repeats and tosses a pair once printed. Cast in order or appearance.&lt;BR /&gt;&lt;BR /&gt;Or this....&lt;BR /&gt;Sort first by key 2, then look and remember.&lt;BR /&gt;This breaks on a 3rd pair as written.&lt;BR /&gt;&lt;BR /&gt;$ sort -k 2 x | perl -ne '($a,$b)=split; print "$x $y\n$a $b\n" if $a ne $x and $b eq $y; $x=$a; $y=$b'&lt;BR /&gt;474 662&lt;BR /&gt;999 662&lt;BR /&gt;123 789&lt;BR /&gt;515 789&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I think you want this....&lt;BR /&gt;&lt;BR /&gt;----------- x.pl ----------&lt;BR /&gt;($left,$right)=split;&lt;BR /&gt;$prior = $seen{$right};&lt;BR /&gt;if (defined $prior) {&lt;BR /&gt;   if ($left ne $prior) {&lt;BR /&gt;      print "$prior $right\n" unless $header{$right}++;&lt;BR /&gt;      print "$left $right\n";&lt;BR /&gt;      }&lt;BR /&gt;   } else {&lt;BR /&gt;   $seen{$right} = $left;&lt;BR /&gt;   }&lt;BR /&gt;----------------------------&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Oct 2007 21:42:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089232#M92222</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-19T21:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089233#M92223</link>
      <description>I want every line returned where the same value in field two has multiple values in field one.   So there could be two or more lines returned for each value in field two.  Does that explain it?  Thanks for your assistance!</description>
      <pubDate>Fri, 19 Oct 2007 22:34:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089233#M92223</guid>
      <dc:creator>TDW</dc:creator>
      <dc:date>2007-10-19T22:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089234#M92224</link>
      <description>After reading your response again, I think I need to explain a little more.&lt;BR /&gt;&lt;BR /&gt;I just need to see every combination once where the second field has more than one value in field one.&lt;BR /&gt;&lt;BR /&gt;So from this list:&lt;BR /&gt;&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;333 662&lt;BR /&gt;123 457&lt;BR /&gt;474 662&lt;BR /&gt;811 363&lt;BR /&gt;474 662&lt;BR /&gt;&lt;BR /&gt;return:&lt;BR /&gt;&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;333 662&lt;BR /&gt;&lt;BR /&gt;That help?</description>
      <pubDate>Fri, 19 Oct 2007 22:40:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089234#M92224</guid>
      <dc:creator>TDW</dc:creator>
      <dc:date>2007-10-19T22:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089235#M92225</link>
      <description>That's what my final piece of code will do when put into a file and executed as...&lt;BR /&gt;&lt;BR /&gt;perl -n x.pl x&lt;BR /&gt;&lt;BR /&gt;Did you try?&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Oct 2007 23:27:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089235#M92225</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-19T23:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089236#M92226</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Here's another approach:&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my %seen;&lt;BR /&gt;my ( $first, $second );&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    ( $first, $second ) = split;&lt;BR /&gt;    push( @{ $seen{$second} }, $first );&lt;BR /&gt;}&lt;BR /&gt;for $second ( sort keys %seen ) {&lt;BR /&gt;    next if scalar( @{ $seen{$second} } ) == 1;&lt;BR /&gt;    for $first ( sort @{ $seen{$second} } ) {&lt;BR /&gt;        print "$first $second\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# sort -u file | ./filter&lt;BR /&gt;333 662&lt;BR /&gt;474 662&lt;BR /&gt;999 662&lt;BR /&gt;&lt;BR /&gt;The code begins by using a 'sort' to eliminate duplicate lines.  The Perl script splits the lines into two pieces.  The second element is used as a hash key and each first element pushed into an array associated with that key.&lt;BR /&gt;&lt;BR /&gt;When all the data has been assimilated, arrays with only one element are skipped.  The remaining elements of each array are then printed as associated with their hash key.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Sat, 20 Oct 2007 10:03:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089236#M92226</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-20T10:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089237#M92227</link>
      <description>&lt;!--!*#--&gt;Try the awk construct below. It does what you are looking for:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt;  x[$2]++&lt;BR /&gt;  if (f[$2]) {&lt;BR /&gt;    if ($0!=f[$2]) f[$2]=f[$2]"\n"$0&lt;BR /&gt;    else delete f[$2]&lt;BR /&gt;  } else f[$2]=$0&lt;BR /&gt;} END {for (i in f) if (x[i]&amp;gt;1) print f[i]}' file</description>
      <pubDate>Sat, 20 Oct 2007 12:44:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089237#M92227</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-20T12:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089238#M92228</link>
      <description>&lt;!--!*#--&gt;Hi (again):&lt;BR /&gt;&lt;BR /&gt;Instead of having to externally sort and pipe the sorted file to the Perl script, you can use this version:&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my %seen;&lt;BR /&gt;my ( $first, $second );&lt;BR /&gt;open( FH, "-|", "sort", "-u", @ARGV ) or die;&lt;BR /&gt;while (&lt;FH&gt;) {&lt;BR /&gt;    ( $first, $second ) = split;&lt;BR /&gt;    push( @{ $seen{$second} }, $first );&lt;BR /&gt;}&lt;BR /&gt;for $second ( sort keys %seen ) {&lt;BR /&gt;    next if scalar( @{ $seen{$second} } ) == 1;&lt;BR /&gt;    for $first ( sort @{ $seen{$second} } ) {&lt;BR /&gt;        print "$first $second\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...now, simply do:&lt;BR /&gt;&lt;BR /&gt;# ./filter file&lt;BR /&gt;333 662&lt;BR /&gt;474 662&lt;BR /&gt;999 662&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/FH&gt;</description>
      <pubDate>Sat, 20 Oct 2007 13:20:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089238#M92228</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-20T13:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089239#M92229</link>
      <description>Base on the sample input provided viz...&lt;BR /&gt;&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;333 662&lt;BR /&gt;123 457&lt;BR /&gt;474 662&lt;BR /&gt;811 363&lt;BR /&gt;474 662&lt;BR /&gt;&lt;BR /&gt;Disregard my last post and instead use the script posted below...&lt;BR /&gt;&lt;BR /&gt;# sort -u file | awk '{i=$2;x[i]++;f[i]=f[i]?f[i]"\n"$0:$0}END{for(j in f) if(x[j]&amp;gt;1) print f[j]}'&lt;BR /&gt;333 662&lt;BR /&gt;474 662&lt;BR /&gt;999 662&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
      <pubDate>Sat, 20 Oct 2007 13:35:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089239#M92229</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-20T13:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089240#M92230</link>
      <description>( It this horse dead yet?  :-)&lt;BR /&gt;&lt;BR /&gt;JRF, Sandman,...&lt;BR /&gt;&lt;BR /&gt;Once one decides on sorting anyway, then sort it properly and there is no longer a need to remember anything but the last value pair! So no 'end' processing is needed.&lt;BR /&gt;&lt;BR /&gt;sort -k 2 -k 1 -u file | awk 's2!=$2 {s1=$1;s2=$2;next} s1!="" {print s1,s2; s1=""} {print}'&lt;BR /&gt;&lt;BR /&gt;explanation:&lt;BR /&gt;&lt;BR /&gt;- sort by second column first, first colum next, eliminate dups.&lt;BR /&gt;- feed into awk (or perl or...)&lt;BR /&gt;- if saved-second was not current second then save the current value pair, and be done, issueing a 'next' ready for the next matching.&lt;BR /&gt;- (else saved-second was equal to current second)&lt;BR /&gt;- if saved-first not empty then print saved value pair and ark as printed by clearing saved-first.&lt;BR /&gt;- print current line&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I like the way JRF makes the 'seen' array entries lists.&lt;BR /&gt;Here is a solution using that technique, but not requiring a sort, thos the output will be in order of input, with the requested restrictions:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;my %seen;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  my ($left,$right)=split;&lt;BR /&gt;  if (defined $seen{$right}) {  # seen before?&lt;BR /&gt;    my @prior = @{$seen{$right}}; # grab current list&lt;BR /&gt;    next if grep (/^$left/,@prior); # eleminate dups&lt;BR /&gt;    print "@prior[0] $right\n" if (1==@prior); # first time?&lt;BR /&gt;    print; &lt;BR /&gt;  }&lt;BR /&gt;  push ( @{$seen{$right}}, $left); # remember this one&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sun, 21 Oct 2007 12:57:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089240#M92230</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-21T12:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089241#M92231</link>
      <description>Thanks for the replies guys!  All three of you came up with a viable solution via different methods.  They all return these values from my original test data:&lt;BR /&gt;&lt;BR /&gt;474 662&lt;BR /&gt;999 662&lt;BR /&gt;123 789&lt;BR /&gt;515 789&lt;BR /&gt;&lt;BR /&gt;Hein, the last code you gave seems to start running and then hang , like this:&lt;BR /&gt;&lt;BR /&gt;perl -n perlHein.pl /tmp/testdata&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;&lt;BR /&gt;Not sure why that is happening.&lt;BR /&gt;&lt;BR /&gt;Thanks much for sharing your skill!</description>
      <pubDate>Sun, 21 Oct 2007 21:55:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089241#M92231</guid>
      <dc:creator>TDW</dc:creator>
      <dc:date>2007-10-21T21:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089242#M92232</link>
      <description>&lt;!--!*#--&gt;in my first solutions I used "perl -n x.pl x&lt;BR /&gt;&lt;BR /&gt;The x.pl is the perl script text&lt;BR /&gt;The x was the data file name&lt;BR /&gt;The -n tell perls to create an implied loop to process each input line.&lt;BR /&gt;&lt;BR /&gt;The last solution was presented as a full program, invoking perl itself, and with the loop explicitly coded.&lt;BR /&gt;Loop: while (&amp;lt;&amp;gt;) {&lt;BR /&gt;&lt;BR /&gt;That solution should be invoked with:  &lt;BR /&gt;    ./script_name file_name&lt;BR /&gt;Sorry for not making that clear.&lt;BR /&gt;And I forgot to mark the 'retain formattng' option while posting, so the loop was not visibile with the indenting either!&lt;BR /&gt;&lt;BR /&gt;The 'hang' is reading from STDIN for more data to process.&lt;BR /&gt;&lt;BR /&gt;Sorry 'bout that confusion!&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sun, 21 Oct 2007 22:08:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089242#M92232</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-21T22:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089243#M92233</link>
      <description>Agree with JRF that there is no need to first sort the file and then pipe it to an external program when the entire procedure can be scripted within awk. That said here is an improved version of the awk construct posted earlier:&lt;BR /&gt;&lt;BR /&gt;# cat file&lt;BR /&gt;123 789&lt;BR /&gt;234 500&lt;BR /&gt;999 662&lt;BR /&gt;373 881&lt;BR /&gt;474 662&lt;BR /&gt;611 200&lt;BR /&gt;515 789&lt;BR /&gt;809 424&lt;BR /&gt;234 500&lt;BR /&gt;&lt;BR /&gt;# awk '{i=$2;if(x[i] &amp;amp;&amp;amp; x[i]!=$1) print x[i],i"\n"$0;x[i]=$1}' file&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;123 789&lt;BR /&gt;515 789</description>
      <pubDate>Mon, 22 Oct 2007 01:45:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089243#M92233</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-22T01:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089244#M92234</link>
      <description>Sandman!&lt;BR /&gt;&lt;BR /&gt;Two rules to practice thsi week...&lt;BR /&gt;&lt;BR /&gt;1) As simple as possible, but no simpler&lt;BR /&gt;2) leave well enough alone&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Your new examples only work for certain data sets. It's much similar to my first solution and fails for much the same reason&lt;BR /&gt;It remembers only left value for a given right value, where there might be a list.&lt;BR /&gt;And on each 'fresh' value it reprints the save values potentially making fresh dups as it goes. Try this data set...&lt;BR /&gt;999 662&lt;BR /&gt;474 662&lt;BR /&gt;333 662&lt;BR /&gt;123 457&lt;BR /&gt;474 662&lt;BR /&gt;811 363&lt;BR /&gt;474 662&lt;BR /&gt;123 789&lt;BR /&gt;234 500&lt;BR /&gt;999 662&lt;BR /&gt;373 881&lt;BR /&gt;474 662&lt;BR /&gt;611 200&lt;BR /&gt;515 789&lt;BR /&gt;809 424&lt;BR /&gt;234 500&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Oct 2007 06:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089244#M92234</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-22T06:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Pull data from file with script tool?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089245#M92235</link>
      <description>&lt;!--!*#--&gt;Good point Hein as I found out on closer inspection and with the dataset you supplied. And yes your Perl code is algorithmically similar to the one I wrote in awk.&lt;BR /&gt;&lt;BR /&gt;Each record in the input file is replaced by the succeeding one and since the file is not sorted the dups fall thru the cracks. But this horse ain't dead yet ;) so here is the final version of the awk construct.&lt;BR /&gt;&lt;BR /&gt;awk '{&lt;BR /&gt;  if (x[$0]!=$0) {&lt;BR /&gt;    y[$2]=(y[$2]?y[$2]"\n"$0:$0); z[$2]++&lt;BR /&gt;  } x[$0]=$0&lt;BR /&gt;}END{&lt;BR /&gt;  for (i in y) if (z[i]&amp;gt;1) print y[i]&lt;BR /&gt;}' file</description>
      <pubDate>Mon, 22 Oct 2007 11:19:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pull-data-from-file-with-script-tool/m-p/4089245#M92235</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-22T11:19:59Z</dc:date>
    </item>
  </channel>
</rss>

