<?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: Writing a Script: du -k in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354062#M192964</link>
    <description>Hi Sai,&lt;BR /&gt;# du -k | sort -k 1,1&lt;BR /&gt;This works for me.&lt;BR /&gt;&lt;BR /&gt;for e.g.&lt;BR /&gt;&lt;BR /&gt;# pwd&lt;BR /&gt;/home&lt;BR /&gt;# du -k&lt;BR /&gt;0       ./lost+found&lt;BR /&gt;8       ./one&lt;BR /&gt;8       ./two&lt;BR /&gt;16      .&lt;BR /&gt;# du -k | sort -k 1,1&lt;BR /&gt;0       ./lost+found&lt;BR /&gt;16      .&lt;BR /&gt;8       ./one&lt;BR /&gt;8       ./two&lt;BR /&gt;# ls -al&lt;BR /&gt;total 16&lt;BR /&gt;drwxr-xr-x   5 root       root            96 Aug 11 12:54 .&lt;BR /&gt;drwxr-xr-x  15 root       root          8192 Aug 10 19:02 ..&lt;BR /&gt;drwxr-xr-x   2 root       root            96 Aug  9 18:12 lost+found&lt;BR /&gt;drwxrwxrwx   2 root       sys             96 Aug 11 12:54 one&lt;BR /&gt;drwxrwxrwx   2 root       sys             96 Aug 11 12:54 two&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
    <pubDate>Wed, 11 Aug 2004 02:28:41 GMT</pubDate>
    <dc:creator>Bharat Katkar</dc:creator>
    <dc:date>2004-08-11T02:28:41Z</dc:date>
    <item>
      <title>Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354061#M192963</link>
      <description>Hello,&lt;BR /&gt;Please helpme out in writing a script for the below scenario:&lt;BR /&gt;&lt;BR /&gt;I have /Home directory under which i have all the User's Home directory as shown below. I have to write a script which should generate an output showing User Home Directory, Disk Space Used in KB, % Disk Space Used in descending order.&lt;BR /&gt;&lt;BR /&gt;bdf command ouput for /Home:&lt;BR /&gt;/vol/vol1/home/tatc-in 73400320 63090040 10310280   86% /tmp_mnt/home/&lt;BR /&gt;&lt;BR /&gt;Directories under /Home:&lt;BR /&gt;cmuluktl     d03013       d03019       mappukut     sprashan&lt;BR /&gt;DEL1.KAL     d03001       d03014       d03020       mprakash     sramanat&lt;BR /&gt;FINAL        d03004       d03015       d03021       report_disk  twr16&lt;BR /&gt;USftp        d03005       d03016       d03023       sdhondi      twr17&lt;BR /&gt;anandam      d03009       d03017       indiaftp     skondapa     vbojja&lt;BR /&gt;apemmara     d03010       d03018       kkomati      smasabat&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sai</description>
      <pubDate>Wed, 11 Aug 2004 02:16:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354061#M192963</guid>
      <dc:creator>sai.prashant</dc:creator>
      <dc:date>2004-08-11T02:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354062#M192964</link>
      <description>Hi Sai,&lt;BR /&gt;# du -k | sort -k 1,1&lt;BR /&gt;This works for me.&lt;BR /&gt;&lt;BR /&gt;for e.g.&lt;BR /&gt;&lt;BR /&gt;# pwd&lt;BR /&gt;/home&lt;BR /&gt;# du -k&lt;BR /&gt;0       ./lost+found&lt;BR /&gt;8       ./one&lt;BR /&gt;8       ./two&lt;BR /&gt;16      .&lt;BR /&gt;# du -k | sort -k 1,1&lt;BR /&gt;0       ./lost+found&lt;BR /&gt;16      .&lt;BR /&gt;8       ./one&lt;BR /&gt;8       ./two&lt;BR /&gt;# ls -al&lt;BR /&gt;total 16&lt;BR /&gt;drwxr-xr-x   5 root       root            96 Aug 11 12:54 .&lt;BR /&gt;drwxr-xr-x  15 root       root          8192 Aug 10 19:02 ..&lt;BR /&gt;drwxr-xr-x   2 root       root            96 Aug  9 18:12 lost+found&lt;BR /&gt;drwxrwxrwx   2 root       sys             96 Aug 11 12:54 one&lt;BR /&gt;drwxrwxrwx   2 root       sys             96 Aug 11 12:54 two&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2004 02:28:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354062#M192964</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2004-08-11T02:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354063#M192965</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try this script:&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;OUTPUT=" Kb      Directory"&lt;BR /&gt;DIRS=`ll|grep ^d|awk '{ print $9}'`&lt;BR /&gt;for DIR in $DIRS&lt;BR /&gt;do&lt;BR /&gt;  OUTPUT="$OUTPUT\n`du -ks $DIR`"&lt;BR /&gt;done&lt;BR /&gt;echo "$OUTPUT"|sort -n&lt;BR /&gt;&lt;BR /&gt;Rgds,</description>
      <pubDate>Wed, 11 Aug 2004 02:50:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354063#M192965</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2004-08-11T02:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354064#M192966</link>
      <description>Sai,&lt;BR /&gt;sorry for that.. little confusion...&lt;BR /&gt;This should work.&lt;BR /&gt;# du -k | sort -k 1n,1&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2004 02:53:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354064#M192966</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2004-08-11T02:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354065#M192967</link>
      <description>There are a couple of perl offerings in the old "system admin" scripts thread.&lt;BR /&gt;&lt;BR /&gt;See ernesto's here:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and Ben Sachs&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x836cc1c4ceddd61190050090279cd0f9%2C00.html&amp;amp;admit=716493758+1092210687681+28353475" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x836cc1c4ceddd61190050090279cd0f9%2C00.html&amp;amp;admit=716493758+1092210687681+28353475&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;There is a gold mone of scripts in the 3 threads.</description>
      <pubDate>Wed, 11 Aug 2004 02:54:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354065#M192967</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2004-08-11T02:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354066#M192968</link>
      <description>Sai&lt;BR /&gt;&lt;BR /&gt;Here's a handy one:&lt;BR /&gt;&lt;BR /&gt;rm /tmp/du_dir_list 2&amp;gt;/dev/null&lt;BR /&gt;rm /tmp/du_dir_list2 2&amp;gt;/dev/null&lt;BR /&gt;echo " "&lt;BR /&gt;echo "FILES:"&lt;BR /&gt;echo " "&lt;BR /&gt;ll | grep -v ^d |sort -k 5n&lt;BR /&gt;&lt;BR /&gt;ll | grep ^d |cut -c59- &amp;gt; /tmp/du_dir_list&lt;BR /&gt;if [ -s /tmp/du_dir_list ]&lt;BR /&gt;then&lt;BR /&gt;        echo " "&lt;BR /&gt;        echo "DIRECTORIES (in Kb):"&lt;BR /&gt;        echo " "&lt;BR /&gt;        for dirname in `cat /tmp/du_dir_list`&lt;BR /&gt;        do&lt;BR /&gt;        du -sk $dirname | awk '{ printf("%8d %s\n",$1,$2) }' &amp;gt;&amp;gt;/tmp/du_dir_list2&lt;BR /&gt;        done&lt;BR /&gt;        sort /tmp/du_dir_list2&lt;BR /&gt;        else&lt;BR /&gt;        echo " "&lt;BR /&gt;        echo "There are no Directories:"&lt;BR /&gt;        echo " "&lt;BR /&gt;fi&lt;BR /&gt;rm /tmp/du_dir_list 2&amp;gt;/dev/null&lt;BR /&gt;rm /tmp/du_dir_list2 2&amp;gt;/dev/null&lt;BR /&gt;echo " "&lt;BR /&gt;bdf .</description>
      <pubDate>Wed, 11 Aug 2004 03:52:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354066#M192968</guid>
      <dc:creator>Michael Campbell</dc:creator>
      <dc:date>2004-08-11T03:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354067#M192969</link>
      <description>To sort the directories in descending order:&lt;BR /&gt;&lt;BR /&gt;du -k|sort -k1,1nr&lt;BR /&gt;&lt;BR /&gt;The nr specifies numerical reverse (default is smallest first)&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Wed, 11 Aug 2004 04:22:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354067#M192969</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2004-08-11T04:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354068#M192970</link>
      <description>&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?admit=716493758+1085211538437+28353475#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?admit=716493758+1085211538437+28353475#33&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2004 04:28:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354068#M192970</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2004-08-11T04:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Writing a Script: du -k</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354069#M192971</link>
      <description>You can do with the following script simply &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for user in `ls /home`; do&lt;BR /&gt;&lt;BR /&gt;  fssize=`bdf /home | grep -v "^Filesystem" | awk '{ print $2 }'`&lt;BR /&gt;  homesize=`du -ks /home/$user | grep -v "^Filesystem" | awk '{ print $1 }'`&lt;BR /&gt;&lt;BR /&gt;  if [[ $homesize -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    per=$(echo "$homesize       $fssize" | awk '{ print $1/$2*100 }')&lt;BR /&gt;  else&lt;BR /&gt;    per=0&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;  home=`du -ks /home/$user | awk '{ print $2 }'`&lt;BR /&gt;&lt;BR /&gt;  echo "$home               $homesize        $fssize         $per %"&lt;BR /&gt;done &amp;gt;&amp;gt; /tmp/form.log&lt;BR /&gt;echo "HOME DIRECTORY            USAGE   DISK SPAGE    %DISK SPACE USAGE"&lt;BR /&gt;cat /tmp/form.log | sort -r -k 4&lt;BR /&gt;rm -f /tmp/form.log&lt;BR /&gt;&lt;BR /&gt;## end ###&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;=======&lt;BR /&gt;# ksh /tmp/form.ksh&lt;BR /&gt;HOME DIRECTORY            USAGE   DISK SPAGE    %DISK SPACE USAGE&lt;BR /&gt;/home/muthu               3152        32768         9.61914 %&lt;BR /&gt;/home/testusr               32        32768         0.0976562 %&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Muthu&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2004 04:50:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/writing-a-script-du-k/m-p/3354069#M192971</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-11T04:50:36Z</dc:date>
    </item>
  </channel>
</rss>

