<?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: !! How to compare between these two lines and get the latest one!! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168837#M681817</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Dennis inadvertantly reversed the order of the sort.  You want"&lt;BR /&gt;&lt;BR /&gt;# sort -r -k5.7,5.10 -k5.1,5.2 -k5.4,5.5 tmp|head -1&lt;BR /&gt;&lt;BR /&gt;...which sorts on the second date's year, then month, then day.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 08 Apr 2009 21:54:43 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-04-08T21:54:43Z</dc:date>
    <item>
      <title>!! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168833#M681813</link>
      <description>I have a unique situation here which looks easier at first but I am not able to solve it.&lt;BR /&gt;&lt;BR /&gt;# SSort UNIX 10/14/2005 10/13/2010 "tox" "9000/800" 16 * * * V849-6-1&lt;BR /&gt;# SSort UNIX 11/31/1996 11/02/2010 "tox" "9000/800" 16 * * * W237-S-2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have a text file with two or multiple values like this and what I am trying to do is compare these lines and just keep the line with the latest date on it.&lt;BR /&gt;&lt;BR /&gt;Note: every line have two dates but the one we have to look at is the second date &lt;BR /&gt;10/13/2010 in first line and 11/02/2010&lt;BR /&gt;in second line.&lt;BR /&gt;&lt;BR /&gt;Any way to do it using unix commands?&lt;BR /&gt;&lt;BR /&gt;I can compare two dates with this command and print the required one &lt;BR /&gt;if the file name is tmp I can do this and get the latest date&lt;BR /&gt;cat tmp|awk '{print $5}'|sort -t '|' -k3n -k1n -k2n|sed '$!d'&lt;BR /&gt;&lt;BR /&gt;but what I want is the entire line like this&lt;BR /&gt;# SSort UNIX 11/31/1996 11/02/2010 "tox" "9000/800" 16 * * * W237-S-2&lt;BR /&gt;&lt;BR /&gt;not only date value.&lt;BR /&gt;&lt;BR /&gt;could anyone help me how can I do it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Apr 2009 20:51:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168833#M681813</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-08T20:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168834#M681814</link>
      <description>You want the one line out of the whole file that has the latest date?&lt;BR /&gt;&lt;BR /&gt;sort -r -k5.7,5.10 -k5.4,5.5 -k5.1,5.2 tmp | head -1</description>
      <pubDate>Wed, 08 Apr 2009 21:12:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168834#M681814</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-08T21:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168835#M681815</link>
      <description>HI:&lt;BR /&gt;&lt;BR /&gt;If you have multiple pairs of lines you could use 'awk' to read two lines at a time' split the line into its component fields; rejoin the date in a YYYYMMDD order and compare the records, printing the "larger" date.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 08 Apr 2009 21:17:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168835#M681815</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-08T21:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168836#M681816</link>
      <description>cat tmp&lt;BR /&gt;# SSort UNIX 10/14/2005 10/13/2010 "tox" "9000/800" 16 * * * V849-6-1&lt;BR /&gt;# SSort UNIX 11/31/1996 11/02/2010 "tox" "9000/800" 16 * * * W237-S-2&lt;BR /&gt;&lt;BR /&gt;when I run your command i got this output &lt;BR /&gt;# SSort UNIX 12/14/2005 10/13/2010 "tox" "9000/800" 16 * * * V849-6-1&lt;BR /&gt;&lt;BR /&gt;which is not right. &lt;BR /&gt;You are right I want the line with the latest date but the other one is latest&lt;BR /&gt; # SSort UNIX 11/31/1996 11/02/2010 "tox" "9000/800" 16 * * * W237-S-2&lt;BR /&gt;Note: I need to compare the second date field not the first&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Apr 2009 21:22:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168836#M681816</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-08T21:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168837#M681817</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Dennis inadvertantly reversed the order of the sort.  You want"&lt;BR /&gt;&lt;BR /&gt;# sort -r -k5.7,5.10 -k5.1,5.2 -k5.4,5.5 tmp|head -1&lt;BR /&gt;&lt;BR /&gt;...which sorts on the second date's year, then month, then day.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 08 Apr 2009 21:54:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168837#M681817</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-08T21:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168838#M681818</link>
      <description>&amp;gt;JRF: Dennis inadvertently reversed the order of the sort.&lt;BR /&gt;&lt;BR /&gt;Oops, wrong field order.  It would work for Europe.  :-)&lt;BR /&gt;That's why dates should always be YYYY/MM/DD so you can sort on the whole field.</description>
      <pubDate>Wed, 08 Apr 2009 22:11:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168838#M681818</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-08T22:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: !! How to compare between these two lines and get the latest one!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168839#M681819</link>
      <description>Thanks guys its working &lt;BR /&gt;Dennis you are right that would have worked in Europe but anyway its working in states too now heheh.&lt;BR /&gt;&lt;BR /&gt;The solution Dennis gave was right but he just did it opposite which was corrected by james.&lt;BR /&gt;I appreciate the help&lt;BR /&gt;Cheers!!!</description>
      <pubDate>Thu, 09 Apr 2009 15:39:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-between-these-two-lines-and-get-the-latest-one/m-p/5168839#M681819</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-09T15:39:30Z</dc:date>
    </item>
  </channel>
</rss>

