<?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: sorting help urgent in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905917#M96789</link>
    <description>A possible problem with Hemmetter's solution is that there are two formats for the messages.  If there are any fewer words in the message, it will fail.  A possibly safer sort command is:&lt;BR /&gt; $ sort -t- -k2,2 283372.txt&lt;BR /&gt;&lt;BR /&gt;Unfortunately it does an ascii sort, not numeric.  But Peter has solved that problem.&lt;BR /&gt;&lt;BR /&gt;In Peter's solution, you can combine the first two seds and the last two:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;sed -e 's/- line/*/' -e 's/,field/*/' data |&lt;BR /&gt;sort -t'*' -k2,2n -k3,3n |&lt;BR /&gt;sed -e 's/*/- line/"' -e 's/*/,field/'</description>
    <pubDate>Thu, 30 Nov 2006 22:27:40 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2006-11-30T22:27:40Z</dc:date>
    <item>
      <title>sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905912#M96784</link>
      <description>I have an input file attached!!&lt;BR /&gt;&lt;BR /&gt;I need the output to be sorted by the line number along with the record number as well.&lt;BR /&gt;(both line and record number are specified in the file).&lt;BR /&gt;for the lines where field number is not given, they shud be sorted along the line sorting.</description>
      <pubDate>Thu, 30 Nov 2006 06:27:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905912#M96784</guid>
      <dc:creator>viseshu</dc:creator>
      <dc:date>2006-11-30T06:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905913#M96785</link>
      <description>Hi,&lt;BR /&gt;my solution would be delimiter replacement:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;sed "s/- line/*/" data &amp;gt; data2&lt;BR /&gt;sed "s/,field/*/" data2 &amp;gt; data3&lt;BR /&gt;sort -t'*' -k 2,2n -k 3,3n data3 &amp;gt; data4&lt;BR /&gt;sed "s/*/- line/" data4 &amp;gt; data5&lt;BR /&gt;sed "s/*/,field/" data5 &amp;gt; data6&lt;BR /&gt;cat data6&lt;BR /&gt;&lt;BR /&gt;If you input file is called data it substitues the "- line" with a "*" and repeats with ",field".&lt;BR /&gt;Then a sort is carried out to sort first on line, then on field.&lt;BR /&gt;Then the placeholders are replaced with their initial values.&lt;BR /&gt;You need to use a unique delimiter ! Base din your inputfile I used "*", you may need to use something else.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Nov 2006 06:58:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905913#M96785</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-11-30T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905914#M96786</link>
      <description>&lt;!--!*#--&gt;Hi Viseshu:&lt;BR /&gt;&lt;BR /&gt;Here's a simple solution:&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 @list;&lt;BR /&gt;my $line;&lt;BR /&gt;my $field;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    $line  = m/line\s(\d+)/  ? $1 : 0;&lt;BR /&gt;    $field = m/field\s(\d+)/ ? $1 : 0;&lt;BR /&gt;    push @list, sprintf "%6d%6d%s", $line, $field, $_;&lt;BR /&gt;}&lt;BR /&gt;@list = sort @list;&lt;BR /&gt;for $line (@list) {&lt;BR /&gt;    print substr( $line, 12 );&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...Run this passing your input file to be sorted:&lt;BR /&gt;&lt;BR /&gt;# ./filter file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 30 Nov 2006 08:35:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905914#M96786</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-11-30T08:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905915#M96787</link>
      <description>&lt;!--!*#--&gt;Try the awk construct below...&lt;BR /&gt;&lt;BR /&gt;awk -F"-" '{&lt;BR /&gt;  gsub("[\",]"," ",$NF)&lt;BR /&gt;  split($NF,z," ")&lt;BR /&gt;  ml &amp;lt; z[2] ? ml=z[2] : ml&lt;BR /&gt;  mr &amp;lt; z[4] ? mr=z[4] : mr&lt;BR /&gt;  z[4] ? x[z[2]""z[4]]=$0 : x[z[2]""0]=$0&lt;BR /&gt;} END {&lt;BR /&gt;  for (i=0;i&lt;ML&gt;&lt;/ML&gt;    for (j=0;j&lt;MR&gt;&lt;/MR&gt;      if (x[i""j])&lt;BR /&gt;        print x[i""j]&lt;BR /&gt;}' file</description>
      <pubDate>Thu, 30 Nov 2006 12:51:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905915#M96787</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-11-30T12:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905916#M96788</link>
      <description>Hi viseshu,&lt;BR /&gt;&lt;BR /&gt;What about:&lt;BR /&gt;$sort -k9,9n -k10,10n data&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Nov 2006 13:19:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905916#M96788</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2006-11-30T13:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905917#M96789</link>
      <description>A possible problem with Hemmetter's solution is that there are two formats for the messages.  If there are any fewer words in the message, it will fail.  A possibly safer sort command is:&lt;BR /&gt; $ sort -t- -k2,2 283372.txt&lt;BR /&gt;&lt;BR /&gt;Unfortunately it does an ascii sort, not numeric.  But Peter has solved that problem.&lt;BR /&gt;&lt;BR /&gt;In Peter's solution, you can combine the first two seds and the last two:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;sed -e 's/- line/*/' -e 's/,field/*/' data |&lt;BR /&gt;sort -t'*' -k2,2n -k3,3n |&lt;BR /&gt;sed -e 's/*/- line/"' -e 's/*/,field/'</description>
      <pubDate>Thu, 30 Nov 2006 22:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905917#M96789</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-11-30T22:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: sorting help urgent</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905918#M96790</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I would respectively ask, "Didn't you find the other solutions with merit?  Did you try any of them?&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 06 Dec 2006 09:47:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sorting-help-urgent/m-p/3905918#M96790</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-06T09:47:49Z</dc:date>
    </item>
  </channel>
</rss>

