<?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: scripting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818739#M86104</link>
    <description>Frank,&lt;BR /&gt;&lt;BR /&gt;In case procura's script gives syntax errors, try:&lt;BR /&gt;&lt;BR /&gt;perl -ne '1..5 and print,next;$snr=substr($_,56,9);$x{$snr}||=$_;END{for(sort keys%x){print$x{$_}}}'&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
    <pubDate>Fri, 04 Oct 2002 08:31:15 GMT</pubDate>
    <dc:creator>Robin Wakefield</dc:creator>
    <dc:date>2002-10-04T08:31:15Z</dc:date>
    <item>
      <title>scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818731#M86096</link>
      <description>How can you sort on a column of a text file and remove the duplicates from that column?&lt;BR /&gt;&lt;BR /&gt;I assume I can use the sort command, but I haven't had much success w/ it.&lt;BR /&gt;&lt;BR /&gt;attached is a sample output of the file.  I want to sort on the Serial # column and remove duplicates.&lt;BR /&gt;&lt;BR /&gt;tia,&lt;BR /&gt;Frank</description>
      <pubDate>Fri, 04 Oct 2002 01:19:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818731#M86096</guid>
      <dc:creator>Dan Copeland</dc:creator>
      <dc:date>2002-10-04T01:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818732#M86097</link>
      <description>you can use sort -k 5&lt;BR /&gt;&lt;BR /&gt;but I think it may spit it because some of the across the page do not have anything where others have BCV. &lt;BR /&gt;&lt;BR /&gt;So essentially, some have less fields.&lt;BR /&gt;&lt;BR /&gt;For removing the duplicates, you can use uniq&lt;BR /&gt;&lt;BR /&gt;Scott.&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Oct 2002 01:23:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818732#M86097</guid>
      <dc:creator>Scott Van Kalken</dc:creator>
      <dc:date>2002-10-04T01:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818733#M86098</link>
      <description>Hi Frank,&lt;BR /&gt;&lt;BR /&gt;I think the best you use Microsoft Excel.&lt;BR /&gt;&lt;BR /&gt;Ftp the file to your PC.&lt;BR /&gt;In your PC,&lt;BR /&gt;Remove the Headers:&lt;BR /&gt;&lt;BR /&gt;       Device                           Product              Device&lt;BR /&gt;----------------------- --------- --------------------- ------------------&lt;BR /&gt;       Name       Type  Vendor    ID               Rev  Ser Num   Cap (KB)&lt;BR /&gt;----------------------- --------- --------------------- ------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Later you can add them back in.&lt;BR /&gt;&lt;BR /&gt;Open your Ms Excel.&lt;BR /&gt;&lt;BR /&gt;Under File --&amp;gt; Open, choose your .txt file.&lt;BR /&gt;&lt;BR /&gt;After you have successfully import the data, cut &amp;amp; paste the Serial# Column &amp;amp; paste it in the 1st Excel Column&lt;BR /&gt;&lt;BR /&gt;Highlight all the columns.&lt;BR /&gt;&lt;BR /&gt;Under Data --&amp;gt; Sort.&lt;BR /&gt;&lt;BR /&gt;That's it ..... &lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Fri, 04 Oct 2002 01:29:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818733#M86098</guid>
      <dc:creator>Uncle Liew</dc:creator>
      <dc:date>2002-10-04T01:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818734#M86099</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I think there is a little bit difficult to use sort because there are different columns in each row. As I see in your file, there are blank values in the TYPE field and when you using SORT some of the field will shifted.&lt;BR /&gt;&lt;BR /&gt;I'll try my best whether there is any other method to do so or other experts here can do that with SORT ! :)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Patrick</description>
      <pubDate>Fri, 04 Oct 2002 03:27:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818734#M86099</guid>
      <dc:creator>Patrick Chim</dc:creator>
      <dc:date>2002-10-04T03:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818735#M86100</link>
      <description># perl -ne '1..5 and print,next;$snr=substr($_,56,9);$x{$snr}||=$_;END{print$x{$_}for(sort keys%x)}' xx.dta</description>
      <pubDate>Fri, 04 Oct 2002 04:50:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818735#M86100</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-04T04:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818736#M86101</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Can you try the following script,&lt;BR /&gt;&lt;BR /&gt;for i in `cut -c57-66 &lt;YOURFILE&gt; | sort -u`&lt;BR /&gt;do&lt;BR /&gt;grep "$i" &lt;YOURFILE&gt; | head -1&lt;BR /&gt;done &amp;gt; &lt;NEWFILE&gt;&lt;BR /&gt;&lt;BR /&gt;I suggest you to cut off all the header and trailer before you issue this script.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Patrick&lt;/NEWFILE&gt;&lt;/YOURFILE&gt;&lt;/YOURFILE&gt;</description>
      <pubDate>Fri, 04 Oct 2002 05:06:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818736#M86101</guid>
      <dc:creator>Patrick Chim</dc:creator>
      <dc:date>2002-10-04T05:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818737#M86102</link>
      <description>Hi&lt;BR /&gt;if you want only that column in sort and whitout duplicates try this:&lt;BR /&gt;&lt;BR /&gt;more text_file | grep "^/"|cut -c57-64|sort|uniq&lt;BR /&gt;&lt;BR /&gt;bye</description>
      <pubDate>Fri, 04 Oct 2002 08:02:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818737#M86102</guid>
      <dc:creator>Supporto Unix</dc:creator>
      <dc:date>2002-10-04T08:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818738#M86103</link>
      <description>Another one(simple ;) )&lt;BR /&gt;&lt;BR /&gt; # cat &lt;FILENAME&gt;|cut -c57-65|sort -u&lt;BR /&gt;&lt;BR /&gt;Will check all lines, so headers, and unrelevant information should be removed. Could do this with grep for example like this:&lt;BR /&gt; # cat &lt;FILENAME&gt;|grep -i '/dev'|cut -c57-65|sort -u&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Fri, 04 Oct 2002 08:30:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818738#M86103</guid>
      <dc:creator>Bjoern Myrland</dc:creator>
      <dc:date>2002-10-04T08:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818739#M86104</link>
      <description>Frank,&lt;BR /&gt;&lt;BR /&gt;In case procura's script gives syntax errors, try:&lt;BR /&gt;&lt;BR /&gt;perl -ne '1..5 and print,next;$snr=substr($_,56,9);$x{$snr}||=$_;END{for(sort keys%x){print$x{$_}}}'&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Fri, 04 Oct 2002 08:31:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818739#M86104</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-10-04T08:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818740#M86105</link>
      <description>Robin, what version do you use? I think that 'for' as statement modifier works in 5.6.1 as well.&lt;BR /&gt;&lt;BR /&gt;OTOH it might indeed be good to remomber that not all of you run perl-5.8.0, and certainly not like me with the defined-or patches in :)</description>
      <pubDate>Fri, 04 Oct 2002 08:34:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818740#M86105</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-04T08:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818741#M86106</link>
      <description>Hi procura, I tried it on an early 5.004 version (yeah I know), so I'm sure it's OK in later releases.  I was just trying to show what needs to be done if it does fail.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Fri, 04 Oct 2002 08:38:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818741#M86106</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-10-04T08:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818742#M86107</link>
      <description>Try this, you may want to mess about with formatting but it should work&lt;BR /&gt;The results go to file "sortedfile"&lt;BR /&gt;"sorter" is the source file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo "HEADER INFO" &amp;gt; sortedfile&lt;BR /&gt;for snum in `grep rdsk sorter | cut -c57-64 | sort -u`&lt;BR /&gt;do&lt;BR /&gt;        linedets=`grep ${snum} sorter | head -n1`&lt;BR /&gt;        lineSnum=`echo "${linedets}" | cut -c57-64`&lt;BR /&gt;        if [ "$lineSnum"  = "$snum" ]&lt;BR /&gt;        then&lt;BR /&gt;                echo $linedets &amp;gt;&amp;gt; sortedfile&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Oct 2002 08:40:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818742#M86107</guid>
      <dc:creator>Pierce Byrne_1</dc:creator>
      <dc:date>2002-10-04T08:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818743#M86108</link>
      <description>Hi Frank,&lt;BR /&gt;&lt;BR /&gt;This is an awk version, inc. a sort routine:&lt;BR /&gt;&lt;BR /&gt;awk 'NR&amp;lt;8{ print }&lt;BR /&gt;        NR&amp;gt;7 { a[substr($0,56,9)]=$0 }&lt;BR /&gt;        END {&lt;BR /&gt;         i=0&lt;BR /&gt;         for(b in a){&lt;BR /&gt;          array[i]=b&lt;BR /&gt;          i++&lt;BR /&gt;         }&lt;BR /&gt;         for (j=1;j&amp;lt;=i-1; ++j)&lt;BR /&gt;          for (k=j;array[k-1]&amp;gt;array[k];--k){&lt;BR /&gt;           temp=array[k]&lt;BR /&gt;           array[k]=array[k-1]&lt;BR /&gt;           array[k-1]=temp&lt;BR /&gt;         }&lt;BR /&gt;         for (i=0;i&lt;J&gt;&lt;/J&gt;          print a[""array[i]]&lt;BR /&gt;         }&lt;BR /&gt;        }' filename&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Oct 2002 11:29:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818743#M86108</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-10-04T11:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818744#M86109</link>
      <description>Frank,&lt;BR /&gt;&lt;BR /&gt;You can use the -u option of sort.  Or the uniq command.&lt;BR /&gt;&lt;BR /&gt;Sean</description>
      <pubDate>Fri, 04 Oct 2002 12:26:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818744#M86109</guid>
      <dc:creator>Sean OB_1</dc:creator>
      <dc:date>2002-10-04T12:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818745#M86110</link>
      <description>Hi Frank,&lt;BR /&gt;I take it that you only want to write out a   serial number once, namely for the first occurrence of a number of items sharing the same. That is at least what the attached script does. However, headings are messed up.&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Fri, 04 Oct 2002 13:11:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818745#M86110</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-10-04T13:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818746#M86111</link>
      <description>&lt;BR /&gt;Correct me if I'm mistaken, but it looks like you're not using PowerPath. If you were, the last three digits of the serial numbers would be unique to each path. It would serve you best to sort on the first five digits.&lt;BR /&gt;&lt;BR /&gt;Use this PERL script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use integer;&lt;BR /&gt;our $h={};&lt;BR /&gt;our $k;&lt;BR /&gt;while(&amp;lt;&amp;gt;){&lt;BR /&gt;   next if /^\s*$/;&lt;BR /&gt;   print,next unless m[^/];&lt;BR /&gt;   @_ = unpack('A23 A10 A22 A18',$_);&lt;BR /&gt;   @_ = map { (split(/\s+/,$_),undef)[0,1] } @_;&lt;BR /&gt;   $k = ( $_[2] eq 'EMC' )?substr($_[6],0,5):$_[6];&lt;BR /&gt;   $h-&amp;gt;{$k} = $_ unless defined $h-&amp;gt;{$k};&lt;BR /&gt;}&lt;BR /&gt;foreach $k (sort keys %$h) { print $h-&amp;gt;{$k}; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It breaks up the input line from syminq more than you really need just in case you want to manipulate more than just the serial number. It's probably not the most efficient, but it seems to works.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Oct 2002 19:19:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2818746#M86111</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-10-04T19:19:20Z</dc:date>
    </item>
  </channel>
</rss>

