<?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: sub-directory size in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571626#M831107</link>
    <description>Sorry, attachment did not work, here his the script :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;# du in Kbytes, Mbytes, Gbytes&lt;BR /&gt;# ============================&lt;BR /&gt;# usage dumegs [-p directory] [directories]&lt;BR /&gt;# option : -p directory : percent of this parent directory&lt;BR /&gt;# other parameter : directories to display&lt;BR /&gt;&lt;BR /&gt;# fonction du -s&lt;BR /&gt;du_it()&lt;BR /&gt;{&lt;BR /&gt;typeset -R10 vsize&lt;BR /&gt;typeset -R3 vpc&lt;BR /&gt;&lt;BR /&gt;bytes=`du -s $1 | cut -f1`&lt;BR /&gt;&lt;BR /&gt;if (( ${#1} &amp;lt; 8 )) ; then&lt;BR /&gt;   ztab="\t\t\t"&lt;BR /&gt;elif (( ${#1} &amp;lt; 16 )) ; then&lt;BR /&gt;   ztab="\t\t"&lt;BR /&gt;else&lt;BR /&gt;   ztab="\t"&lt;BR /&gt;fi&lt;BR /&gt;if [ $bytes -le 999999 ] ; then&lt;BR /&gt;   bytes=`expr $bytes \* 512`&lt;BR /&gt;   kbytes=`expr $bytes \/ 1024`&lt;BR /&gt;else&lt;BR /&gt;   kbytes=`expr $bytes \/ 2`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $kbytes -gt 999 ] ; then&lt;BR /&gt;   mbytes=`expr $kbytes \/ 1024`&lt;BR /&gt;   xbytes=`expr $mbytes \* 1024`&lt;BR /&gt;   dbytes=`expr $kbytes - $xbytes`&lt;BR /&gt;   if [ $dbytes -le 10 ] ; then&lt;BR /&gt;      dbytes="00$dbytes"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ $dbytes -le 100 ] ; then&lt;BR /&gt;      dbytes="0$dbytes"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ $mbytes -gt 999 ] ; then&lt;BR /&gt;      gbytes=`expr $mbytes \/ 1024`&lt;BR /&gt;      xbytes=`expr $gbytes \* 1024`&lt;BR /&gt;      dbytes=`expr $mbytes - $xbytes`&lt;BR /&gt;      if [ $dbytes -le 10 ] ; then&lt;BR /&gt;         dbytes="00$dbytes"&lt;BR /&gt;      fi&lt;BR /&gt;      if [ $dbytes -le 100 ] ; then&lt;BR /&gt;         dbytes="0$dbytes"&lt;BR /&gt;      fi&lt;BR /&gt;      vsize=$gbytes,$dbytes&lt;BR /&gt;      unit=" Gb"&lt;BR /&gt;   else&lt;BR /&gt;      vsize=$mbytes,$dbytes&lt;BR /&gt;      unit=" Mb"&lt;BR /&gt;   fi&lt;BR /&gt;else&lt;BR /&gt;   vsize=$kbytes&lt;BR /&gt;   unit=" Kb"&lt;BR /&gt;fi&lt;BR /&gt;if [ -n "$optp" ] ; then&lt;BR /&gt;   if [ -n "$tkb" ] ; then&lt;BR /&gt;      vpc=$(expr $kbytes \* 100 \/ $tkb)&lt;BR /&gt;      pc="  $vpc %"&lt;BR /&gt;   else&lt;BR /&gt;      pc=" (parent directory)"&lt;BR /&gt;   fi&lt;BR /&gt;fi&lt;BR /&gt;echo "$1$ztab$vsize$unit$pc"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# main dumegs&lt;BR /&gt;tkb=&lt;BR /&gt;optp=&lt;BR /&gt;optparg=&lt;BR /&gt;while getopts :p: OPT "$@"&lt;BR /&gt;do&lt;BR /&gt;   case $OPT in&lt;BR /&gt;     p)   optp=1 ; optparg=$OPTARG ;;&lt;BR /&gt;     \?)  echo "usage dumegs [-p directory] [directories]" ; exit 1 ;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;if [ -n "$optp" ] ; then&lt;BR /&gt;   if [ -z "$optparg" ] ; then&lt;BR /&gt;      echo "option -p : missing directory parameter"&lt;BR /&gt;      exit 2&lt;BR /&gt;   fi&lt;BR /&gt;   du_it $optparg&lt;BR /&gt;   tkb=$kbytes&lt;BR /&gt;   shift 2&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $# -gt 0 ] ; then&lt;BR /&gt;   for dirs in $*&lt;BR /&gt;   do&lt;BR /&gt;      if [ -d "$dirs" ] ; then&lt;BR /&gt;         du_it $dirs&lt;BR /&gt;      elif  [ -f "$dirs" ] ; then&lt;BR /&gt;         du_it $dirs&lt;BR /&gt;      fi&lt;BR /&gt;   done&lt;BR /&gt;else&lt;BR /&gt;   du_it $PWD&lt;BR /&gt;fi&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 28 Jun 2005 12:03:31 GMT</pubDate>
    <dc:creator>Joel Girot</dc:creator>
    <dc:date>2005-06-28T12:03:31Z</dc:date>
    <item>
      <title>sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571619#M831100</link>
      <description>Dear Sirs,&lt;BR /&gt;&lt;BR /&gt;What is command or script to find sub-directory or directory size in MegaByte (MB) or GB ?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;Shiv</description>
      <pubDate>Mon, 27 Jun 2005 13:26:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571619#M831100</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-06-27T13:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571620#M831101</link>
      <description>$ du -sk subdir&lt;BR /&gt;&lt;BR /&gt;This will give you the size in Kb. Multiply this by 1024 for Mb.&lt;BR /&gt;&lt;BR /&gt;David</description>
      <pubDate>Mon, 27 Jun 2005 13:30:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571620#M831101</guid>
      <dc:creator>David Child_1</dc:creator>
      <dc:date>2005-06-27T13:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571621#M831102</link>
      <description>The 'du' command has these options.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 13:36:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571621#M831102</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-06-27T13:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571622#M831103</link>
      <description>Umm....Actually you would divide the output of 'du -sk' by 1024 to get the size in MB.  Then divide again by 1024 to get GB.&lt;BR /&gt;&lt;BR /&gt;If you multiplied the output by 1024, you'd get the size in BYTES.&lt;BR /&gt;&lt;BR /&gt;Size in KB&lt;BR /&gt;# du -ks /somedir&lt;BR /&gt;1234567890 somedir&lt;BR /&gt;&lt;BR /&gt;Size in MB&lt;BR /&gt;# echo 1234567890/1024|bc -l&lt;BR /&gt;1205632.70507812500000000000&lt;BR /&gt;&lt;BR /&gt;Size in GB&lt;BR /&gt;# echo 1205632.705078125/1024|bc -l&lt;BR /&gt;1177.37568855285644531250&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 13:43:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571622#M831103</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-06-27T13:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571623#M831104</link>
      <description>Hello Shiv,&lt;BR /&gt;&lt;BR /&gt;Size in KB&lt;BR /&gt;echo `du -ks &lt;DIRECTORY&gt; | awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;Size in MB&lt;BR /&gt;echo `du -ks &lt;DIRECTORY&gt; | awk '{print $1}'`/1024|bc -l&lt;BR /&gt;&lt;BR /&gt;Size in GB&lt;BR /&gt;echo `du -ks &lt;DIRECTORY&gt; | awk '{print $1}'`/1024/1024|bc -l&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Ganesha Sridhara&lt;/DIRECTORY&gt;&lt;/DIRECTORY&gt;&lt;/DIRECTORY&gt;</description>
      <pubDate>Tue, 28 Jun 2005 00:08:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571623#M831104</guid>
      <dc:creator>Ganesha Sridhara</dc:creator>
      <dc:date>2005-06-28T00:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571624#M831105</link>
      <description>Hi Shiv&lt;BR /&gt;&lt;BR /&gt;See this attached script, found on this forum. Look like that :&lt;BR /&gt;&lt;BR /&gt;/# dumegs *&lt;BR /&gt;bin                              0 Kb&lt;BR /&gt;cdrom                            0 Kb&lt;BR /&gt;dev                            104 Kb&lt;BR /&gt;etc                         48,712 Mb&lt;BR /&gt;gv0                        118,830 Mb&lt;BR /&gt;gv1                          3,461 Gb&lt;BR /&gt;home                           592 Kb&lt;BR /&gt;lib                              0 Kb&lt;BR /&gt;log                              1 Kb&lt;BR /&gt;lost+found                       0 Kb&lt;BR /&gt;net                              0 Kb&lt;BR /&gt;opt                          1,709 Gb&lt;BR /&gt;root                         4,608 Mb&lt;BR /&gt;sbin                        36,728 Mb&lt;BR /&gt;stand                       40,968 Mb&lt;BR /&gt;tmp                             27 Kb&lt;BR /&gt;tmp_mnt                          0 Kb&lt;BR /&gt;usr                          1,174 Gb&lt;BR /&gt;var                        728,632 Mb&lt;BR /&gt;&lt;BR /&gt;Joel</description>
      <pubDate>Tue, 28 Jun 2005 01:48:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571624#M831105</guid>
      <dc:creator>Joel Girot</dc:creator>
      <dc:date>2005-06-28T01:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571625#M831106</link>
      <description>Hi David&lt;BR /&gt;&lt;BR /&gt;We have to devide by 1024 to get size in MB&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Mahesh</description>
      <pubDate>Tue, 28 Jun 2005 07:04:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571625#M831106</guid>
      <dc:creator>Mahesh Kumar Malik</dc:creator>
      <dc:date>2005-06-28T07:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: sub-directory size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571626#M831107</link>
      <description>Sorry, attachment did not work, here his the script :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;# du in Kbytes, Mbytes, Gbytes&lt;BR /&gt;# ============================&lt;BR /&gt;# usage dumegs [-p directory] [directories]&lt;BR /&gt;# option : -p directory : percent of this parent directory&lt;BR /&gt;# other parameter : directories to display&lt;BR /&gt;&lt;BR /&gt;# fonction du -s&lt;BR /&gt;du_it()&lt;BR /&gt;{&lt;BR /&gt;typeset -R10 vsize&lt;BR /&gt;typeset -R3 vpc&lt;BR /&gt;&lt;BR /&gt;bytes=`du -s $1 | cut -f1`&lt;BR /&gt;&lt;BR /&gt;if (( ${#1} &amp;lt; 8 )) ; then&lt;BR /&gt;   ztab="\t\t\t"&lt;BR /&gt;elif (( ${#1} &amp;lt; 16 )) ; then&lt;BR /&gt;   ztab="\t\t"&lt;BR /&gt;else&lt;BR /&gt;   ztab="\t"&lt;BR /&gt;fi&lt;BR /&gt;if [ $bytes -le 999999 ] ; then&lt;BR /&gt;   bytes=`expr $bytes \* 512`&lt;BR /&gt;   kbytes=`expr $bytes \/ 1024`&lt;BR /&gt;else&lt;BR /&gt;   kbytes=`expr $bytes \/ 2`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $kbytes -gt 999 ] ; then&lt;BR /&gt;   mbytes=`expr $kbytes \/ 1024`&lt;BR /&gt;   xbytes=`expr $mbytes \* 1024`&lt;BR /&gt;   dbytes=`expr $kbytes - $xbytes`&lt;BR /&gt;   if [ $dbytes -le 10 ] ; then&lt;BR /&gt;      dbytes="00$dbytes"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ $dbytes -le 100 ] ; then&lt;BR /&gt;      dbytes="0$dbytes"&lt;BR /&gt;   fi&lt;BR /&gt;   if [ $mbytes -gt 999 ] ; then&lt;BR /&gt;      gbytes=`expr $mbytes \/ 1024`&lt;BR /&gt;      xbytes=`expr $gbytes \* 1024`&lt;BR /&gt;      dbytes=`expr $mbytes - $xbytes`&lt;BR /&gt;      if [ $dbytes -le 10 ] ; then&lt;BR /&gt;         dbytes="00$dbytes"&lt;BR /&gt;      fi&lt;BR /&gt;      if [ $dbytes -le 100 ] ; then&lt;BR /&gt;         dbytes="0$dbytes"&lt;BR /&gt;      fi&lt;BR /&gt;      vsize=$gbytes,$dbytes&lt;BR /&gt;      unit=" Gb"&lt;BR /&gt;   else&lt;BR /&gt;      vsize=$mbytes,$dbytes&lt;BR /&gt;      unit=" Mb"&lt;BR /&gt;   fi&lt;BR /&gt;else&lt;BR /&gt;   vsize=$kbytes&lt;BR /&gt;   unit=" Kb"&lt;BR /&gt;fi&lt;BR /&gt;if [ -n "$optp" ] ; then&lt;BR /&gt;   if [ -n "$tkb" ] ; then&lt;BR /&gt;      vpc=$(expr $kbytes \* 100 \/ $tkb)&lt;BR /&gt;      pc="  $vpc %"&lt;BR /&gt;   else&lt;BR /&gt;      pc=" (parent directory)"&lt;BR /&gt;   fi&lt;BR /&gt;fi&lt;BR /&gt;echo "$1$ztab$vsize$unit$pc"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# main dumegs&lt;BR /&gt;tkb=&lt;BR /&gt;optp=&lt;BR /&gt;optparg=&lt;BR /&gt;while getopts :p: OPT "$@"&lt;BR /&gt;do&lt;BR /&gt;   case $OPT in&lt;BR /&gt;     p)   optp=1 ; optparg=$OPTARG ;;&lt;BR /&gt;     \?)  echo "usage dumegs [-p directory] [directories]" ; exit 1 ;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;if [ -n "$optp" ] ; then&lt;BR /&gt;   if [ -z "$optparg" ] ; then&lt;BR /&gt;      echo "option -p : missing directory parameter"&lt;BR /&gt;      exit 2&lt;BR /&gt;   fi&lt;BR /&gt;   du_it $optparg&lt;BR /&gt;   tkb=$kbytes&lt;BR /&gt;   shift 2&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $# -gt 0 ] ; then&lt;BR /&gt;   for dirs in $*&lt;BR /&gt;   do&lt;BR /&gt;      if [ -d "$dirs" ] ; then&lt;BR /&gt;         du_it $dirs&lt;BR /&gt;      elif  [ -f "$dirs" ] ; then&lt;BR /&gt;         du_it $dirs&lt;BR /&gt;      fi&lt;BR /&gt;   done&lt;BR /&gt;else&lt;BR /&gt;   du_it $PWD&lt;BR /&gt;fi&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Jun 2005 12:03:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sub-directory-size/m-p/3571626#M831107</guid>
      <dc:creator>Joel Girot</dc:creator>
      <dc:date>2005-06-28T12:03:31Z</dc:date>
    </item>
  </channel>
</rss>

