<?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: Perl:  Sort in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008251#M99006</link>
    <description>This is *very* old perl code. And bad style too&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl &lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;# Show the percentage of total used space in /home to each user &lt;BR /&gt;&lt;BR /&gt;my $home_thresh = 1 ; # won't print if it isn't more than 1% &lt;BR /&gt;&lt;BR /&gt;# Get the size of each users home directory &lt;BR /&gt;&lt;BR /&gt;# sub homes_report { &lt;BR /&gt;(my $home_total = `du -sk /home 2&amp;gt; /dev/null`) =~ s/\s.*//s;&lt;BR /&gt;&lt;BR /&gt;print "/home's total usage is $home_total kb \n" ; &lt;BR /&gt;&lt;BR /&gt;my %homes;&lt;BR /&gt;for (`du -sk /home/* 2&amp;gt;/dev/null`) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my ($home_kb, $home_dir) = split m/\s+/;&lt;BR /&gt;    $homes{$home_dir}{size} = $home_kb;&lt;BR /&gt;    my $home_pct = int (($home_kb / $home_total) * 100);&lt;BR /&gt;    $home_pct &amp;gt; $home_thresh or next;&lt;BR /&gt;    $homes{$home_dir}{pct} = $home_pct;&lt;BR /&gt;    } &lt;BR /&gt;&lt;BR /&gt;foreach my $dir (sort { $homes{$b}{pct} &amp;lt;=&amp;gt; $homes{$a}{pct} } keys %homes) {&lt;BR /&gt;    printf "%6.2f%% %s\n", $homes{$dir}{pct}, $dir;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Thu, 12 Oct 2006 08:23:54 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2006-10-12T08:23:54Z</dc:date>
    <item>
      <title>Perl:  Sort</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008250#M99005</link>
      <description>I found this script that I like on these forums.  I don't really know perl at all so I am wondering if someone here can help.  How can I sort the output by the percentage.  So the output would be something like this:&lt;BR /&gt;&lt;BR /&gt;/home/usera (xxxxxxxkb) 45%&lt;BR /&gt;/home/userb (xxxxxxxkb) 20%&lt;BR /&gt;/home/userc (xxxxxxxkb)  5%&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;# Show the percentage of total used space in /home to each user&lt;BR /&gt;# 11/18/02 BRS&lt;BR /&gt;&lt;BR /&gt;$home_thresh = 1 ;  # won't print if it isn't more than 1%&lt;BR /&gt;&lt;BR /&gt;# Get the size of each users home directory&lt;BR /&gt;&lt;BR /&gt;# sub homes_report {&lt;BR /&gt;$home_total = `du -sk /home 2&amp;gt; \/dev\/null`;&lt;BR /&gt;($home_total,$nothing) = split(/\s+/,$home_total) ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;print "/home's total usage is $home_total kb \n" ;&lt;BR /&gt;&lt;BR /&gt;foreach (`du -sk /home/* 2&amp;gt; \/dev\/null` ) {&lt;BR /&gt;        chop ;&lt;BR /&gt;        ($home_kb,$home_dir) = split (/\s+/);&lt;BR /&gt;        $homes_size{$home_dir} = $home_kb ;&lt;BR /&gt;        $home_pct = int(($home_kb / $home_total) * 100) ;&lt;BR /&gt;        if ( $home_pct &amp;gt; $home_thresh ) {&lt;BR /&gt;                print $home_dir ($home_kb kb) is $home_pct% \n" ;&lt;BR /&gt;        }&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Oct 2006 08:05:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008250#M99005</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-10-12T08:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Perl:  Sort</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008251#M99006</link>
      <description>This is *very* old perl code. And bad style too&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl &lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;# Show the percentage of total used space in /home to each user &lt;BR /&gt;&lt;BR /&gt;my $home_thresh = 1 ; # won't print if it isn't more than 1% &lt;BR /&gt;&lt;BR /&gt;# Get the size of each users home directory &lt;BR /&gt;&lt;BR /&gt;# sub homes_report { &lt;BR /&gt;(my $home_total = `du -sk /home 2&amp;gt; /dev/null`) =~ s/\s.*//s;&lt;BR /&gt;&lt;BR /&gt;print "/home's total usage is $home_total kb \n" ; &lt;BR /&gt;&lt;BR /&gt;my %homes;&lt;BR /&gt;for (`du -sk /home/* 2&amp;gt;/dev/null`) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my ($home_kb, $home_dir) = split m/\s+/;&lt;BR /&gt;    $homes{$home_dir}{size} = $home_kb;&lt;BR /&gt;    my $home_pct = int (($home_kb / $home_total) * 100);&lt;BR /&gt;    $home_pct &amp;gt; $home_thresh or next;&lt;BR /&gt;    $homes{$home_dir}{pct} = $home_pct;&lt;BR /&gt;    } &lt;BR /&gt;&lt;BR /&gt;foreach my $dir (sort { $homes{$b}{pct} &amp;lt;=&amp;gt; $homes{$a}{pct} } keys %homes) {&lt;BR /&gt;    printf "%6.2f%% %s\n", $homes{$dir}{pct}, $dir;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 12 Oct 2006 08:23:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008251#M99006</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-10-12T08:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Perl:  Sort</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008252#M99007</link>
      <description>&lt;!--!*#--&gt;Vo tried and found a small glitch.&lt;BR /&gt;Try this instead&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $users = shift || "/users";&lt;BR /&gt;&lt;BR /&gt;# Show the percentage of total used space in /home to each user&lt;BR /&gt;my $home_thresh = 1.; # won't print if it isn't more than 1%&lt;BR /&gt;# Get the size of each users home directory&lt;BR /&gt;# sub homes_report {&lt;BR /&gt;(my $home_total = `du -sk $users 2&amp;gt; /dev/null`) =~ s/\s.*//s;&lt;BR /&gt;print "$users\'s total usage is $home_total kb \n";&lt;BR /&gt;$home_total &amp;gt; 0 or exit;&lt;BR /&gt;&lt;BR /&gt;my %homes;&lt;BR /&gt;for (`du -sk $users/* 2&amp;gt;/dev/null`) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my ($home_kb, $home_dir) = split m/\s+/;&lt;BR /&gt;    $homes{$home_dir}{size} = $home_kb;&lt;BR /&gt;    my $home_pct = int (($home_kb / $home_total) * 100);&lt;BR /&gt;    $homes{$home_dir}{pct} = $home_pct;&lt;BR /&gt;    }&lt;BR /&gt;foreach my $dir (sort { $homes{$b}{pct} &amp;lt;=&amp;gt; $homes{$a}{pct} } keys %homes) {&lt;BR /&gt;    $homes{$dir}{pct} &amp;gt; $home_thresh and&lt;BR /&gt; printf "%6.2f%% %s\n", $homes{$dir}{pct}, $dir;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 13 Oct 2006 06:01:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008252#M99007</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-10-13T06:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Perl:  Sort</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008253#M99008</link>
      <description>Thanks, that second one worked like a charm.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Oct 2006 07:39:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008253#M99008</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-10-13T07:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perl:  Sort</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008254#M99009</link>
      <description>Merijn,&lt;BR /&gt;&lt;BR /&gt;your a genius!!!!!!!!!&lt;BR /&gt;&lt;BR /&gt;Many thanks and 25 pts. from me *1*&lt;BR /&gt;&lt;BR /&gt;Best wishes&lt;BR /&gt;see you&lt;BR /&gt;Volkmar&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Oct 2006 07:45:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-sort/m-p/5008254#M99009</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2006-10-13T07:45:28Z</dc:date>
    </item>
  </channel>
</rss>

