<?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: Group and summarize data in shell script (like in SQL) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288611#M688671</link>
    <description>&lt;!--!*#--&gt;James - that looks fantastic!  The only problem I have is perhaps an overflow situation perhaps?  Here is my output:&lt;BR /&gt;&lt;BR /&gt;There are 542 disks that are 14284801 bytes each totalling -1 bytes&lt;BR /&gt;There are 18 disks that are 21582721 bytes each totalling 388488978 bytes&lt;BR /&gt;There are 1 disks that are 2880 bytes each totalling 2880 bytes&lt;BR /&gt;&lt;BR /&gt;The numbers are all correct except for the "-1".  It should be 7742362142.  Is that due to some overflow in perl, or something else?&lt;BR /&gt;&lt;BR /&gt;Scott</description>
    <pubDate>Thu, 16 Oct 2008 19:31:54 GMT</pubDate>
    <dc:creator>Scott Lindstrom_2</dc:creator>
    <dc:date>2008-10-16T19:31:54Z</dc:date>
    <item>
      <title>Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288609#M688669</link>
      <description>&lt;!--!*#--&gt;I have some data that looks like this:&lt;BR /&gt;&lt;BR /&gt;/dev/rdsk/c8t8d3 EMC SYMMETRIX 2798B000 14284801 2798B000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t8d5 EMC SYMMETRIX 2798D000 14284801 2798D000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t8d7 EMC SYMMETRIX 2798F000 14284801 2798F000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t9d1 EMC SYMMETRIX 27991000 14284801 27991000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t9d3 EMC SYMMETRIX 27993000 14284801 27993000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t9d5 EMC SYMMETRIX 27995000 14284801 27995000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c8t9d7 EMC SYMMETRIX 27997000 14284801 27997000 BCV FIBRE SYMM4 unprotected&lt;BR /&gt;/dev/rdsk/c18t2d5 EMC SYMMETRIX 27601008 21582721 27601008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t2d7 EMC SYMMETRIX 27603008 21582721 27603008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t3d1 EMC SYMMETRIX 27605008 21582721 27605008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t3d3 EMC SYMMETRIX 27607008 21582721 27607008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t3d5 EMC SYMMETRIX 27609008 21582721 27609008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t3d7 EMC SYMMETRIX 2760C008 21582721 2760C008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t4d1 EMC SYMMETRIX 2760E008 21582721 2760E008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;/dev/rdsk/c18t4d2 EMC SYMMETRIX 2712B008 21582721 2712B008 REG FIBRE SYMM4 RAID-S&lt;BR /&gt;&lt;BR /&gt;I'd like to be able to read this file and output some messages like:&lt;BR /&gt;&lt;BR /&gt;There are 7 disks that are 14284801 bytes each totalling 99993607 bytes&lt;BR /&gt;There are 8 disks that are 21582721 bytes each totalling 172661768 bytes&lt;BR /&gt;&lt;BR /&gt;I thought perhaps there was some shell, perl, or whatever command I could use in the ksh script to sort, count, and summarize on the 5th field (the disk size).  Can anyone point me in the correct direction to look?&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Thu, 16 Oct 2008 18:30:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288609#M688669</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2008-10-16T18:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288610#M688670</link>
      <description>&lt;!--!*#--&gt;Hi Scott:&lt;BR /&gt;&lt;BR /&gt;One way:&lt;BR /&gt;&lt;BR /&gt;# cat ./groupit&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $size, %disk_sizes, %disk_counts );&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    ($size) = (split)[4];&lt;BR /&gt;    $disk_sizes {$size}+= $size;&lt;BR /&gt;    $disk_counts{$size}++;&lt;BR /&gt;}&lt;BR /&gt;for $size ( sort keys %disk_sizes ) {&lt;BR /&gt;    printf "There are %d disks that are %d bytes each totalling %d bytes\n",&lt;BR /&gt;        $disk_counts{$size}, $size, $disk_sizes{$size};&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./groupit file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 16 Oct 2008 19:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288610#M688670</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-16T19:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288611#M688671</link>
      <description>&lt;!--!*#--&gt;James - that looks fantastic!  The only problem I have is perhaps an overflow situation perhaps?  Here is my output:&lt;BR /&gt;&lt;BR /&gt;There are 542 disks that are 14284801 bytes each totalling -1 bytes&lt;BR /&gt;There are 18 disks that are 21582721 bytes each totalling 388488978 bytes&lt;BR /&gt;There are 1 disks that are 2880 bytes each totalling 2880 bytes&lt;BR /&gt;&lt;BR /&gt;The numbers are all correct except for the "-1".  It should be 7742362142.  Is that due to some overflow in perl, or something else?&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Thu, 16 Oct 2008 19:31:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288611#M688671</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2008-10-16T19:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288612#M688672</link>
      <description>Hi (again) Scott:&lt;BR /&gt;&lt;BR /&gt;The "%d" specification can't handle values larger than 32-bits so use:&lt;BR /&gt;&lt;BR /&gt;# cat ./groupit&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $size, %disk_sizes, %disk_counts );&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    ($size) = (split)[4];&lt;BR /&gt;    $disk_sizes {$size}+= $size;&lt;BR /&gt;    $disk_counts{$size}++;&lt;BR /&gt;}&lt;BR /&gt;for $size ( sort keys %disk_sizes ) {&lt;BR /&gt;    printf "There are %d disks that are %.0f bytes each totalling %.0f bytes\n",&lt;BR /&gt;        $disk_counts{$size}, $size, $disk_sizes{$size};&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 16 Oct 2008 19:46:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288612#M688672</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-16T19:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288613#M688673</link>
      <description>James - that solved that!  &lt;BR /&gt;&lt;BR /&gt;In the meantime I am going to look into how I can display the output as "7.2 GB".  (answer/1024/1024/1024)&lt;BR /&gt;&lt;BR /&gt;(But if you want to chime in the meantime with the way to do it I would be forever grateful)   :-)&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Thu, 16 Oct 2008 19:52:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288613#M688673</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2008-10-16T19:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288614#M688674</link>
      <description>&lt;!--!*#--&gt;Hi Scott:&lt;BR /&gt;&lt;BR /&gt;Change the 'printf' to:&lt;BR /&gt;&lt;BR /&gt;printf "There are %d disks that are %.0f bytes each totalling %7.2f GB\n",&lt;BR /&gt;    $disk_counts{$size}, $size, $disk_sizes{$size}/1024/1024/1024;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...just the way you thought you would!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Oct 2008 20:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288614#M688674</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-10-16T20:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288615#M688675</link>
      <description>A million thanks James!</description>
      <pubDate>Thu, 16 Oct 2008 20:13:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288615#M688675</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2008-10-16T20:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Group and summarize data in shell script (like in SQL)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288616#M688676</link>
      <description>&lt;!--!*#--&gt;Here is something using awk:&lt;BR /&gt;&lt;BR /&gt;sort -k5,5 file | awk '&lt;BR /&gt;function print_entry() {&lt;BR /&gt;   print "There are", count, "disks that are", last, "bytes each totaling",&lt;BR /&gt;          last*count/(1024*1024), "Mb"&lt;BR /&gt;}&lt;BR /&gt;function enter_entry() {&lt;BR /&gt;   last = $5&lt;BR /&gt;   count = 1&lt;BR /&gt;}&lt;BR /&gt;BEGIN { getline; enter_entry() }&lt;BR /&gt;{&lt;BR /&gt;if ($5 == last) {&lt;BR /&gt;   ++count&lt;BR /&gt;   next&lt;BR /&gt;}&lt;BR /&gt;print_entry()&lt;BR /&gt;enter_entry()&lt;BR /&gt;}&lt;BR /&gt;END { print_entry() }'</description>
      <pubDate>Fri, 17 Oct 2008 00:13:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/group-and-summarize-data-in-shell-script-like-in-sql/m-p/4288616#M688676</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-10-17T00:13:30Z</dc:date>
    </item>
  </channel>
</rss>

