<?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: script for total files size in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507375#M365409</link>
    <description>now I'm confusing myself:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; if you really want to gather disk sizes &lt;BR /&gt;&lt;BR /&gt;should of course read:&lt;BR /&gt;&lt;BR /&gt;if you really want to gather and total file sizes &lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
    <pubDate>Sun, 04 Oct 2009 10:55:07 GMT</pubDate>
    <dc:creator>Duncan Edmonstone</dc:creator>
    <dc:date>2009-10-04T10:55:07Z</dc:date>
    <item>
      <title>script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507373#M365407</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Hi Admins,&lt;BR /&gt;&lt;BR /&gt;I want to get the total size of files dated Oct 4 under /data.Find the script which i tried.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;total=0&lt;BR /&gt;files=du -sk `ls -lrt /data | grep "Oct  4"|awk '{print $9}'`&lt;BR /&gt;for filesize in $files&lt;BR /&gt;do&lt;BR /&gt;total=$total+$files&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;But m ended up with error.&lt;BR /&gt;&lt;BR /&gt;./test[3]: -sk:  not found.&lt;BR /&gt;&lt;BR /&gt;Plz suggest on this.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;himacs&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Oct 2009 10:30:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507373#M365407</guid>
      <dc:creator>himacs</dc:creator>
      <dc:date>2009-10-04T10:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507374#M365408</link>
      <description>This shows a fairly major lack of understanding of shell scripting - I suggest you spend some time looking at some online training material on doing shell scripting:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-90046/index.html" target="_blank"&gt;http://docs.hp.com/en/B2355-90046/index.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;why are you using du ?&lt;BR /&gt;&lt;BR /&gt;du will show you disk usage. *not* file size - these are not the same thing...&lt;BR /&gt;&lt;BR /&gt;if you really want to gather disk sizes in this rather crude way, I guess:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;total=0&lt;BR /&gt;sizes=`ls -lrt /data | grep "Oct 4"|awk '{print $5}'`&lt;BR /&gt;for filesize in $sizes&lt;BR /&gt;do&lt;BR /&gt;(( total = $total + $filesize ))&lt;BR /&gt;done&lt;BR /&gt;echo $total&lt;BR /&gt;&lt;BR /&gt;might work for you (untested)&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Oct 2009 10:51:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507374#M365408</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2009-10-04T10:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507375#M365409</link>
      <description>now I'm confusing myself:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; if you really want to gather disk sizes &lt;BR /&gt;&lt;BR /&gt;should of course read:&lt;BR /&gt;&lt;BR /&gt;if you really want to gather and total file sizes &lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Sun, 04 Oct 2009 10:55:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507375#M365409</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2009-10-04T10:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507376#M365410</link>
      <description>&amp;gt; files=du -sk `ls -lrt /data | grep "Oct 4"|awk '{print $9}'`&lt;BR /&gt;&lt;BR /&gt;The above line is equivalent to:&lt;BR /&gt;&lt;BR /&gt;files=du &lt;BR /&gt;-sk `ls -lrt /data | grep "Oct 4"|awk '{print $9}'`&lt;BR /&gt;&lt;BR /&gt;The $files variable got assigned the string "du" and then the system attempted to execute a command named -sk, which of course did not exist.&lt;BR /&gt;&lt;BR /&gt;You would need to use multiple sets of backquotes, which gets confusing and is prone to errors. Fortunately, there is another way: you can use $( ... ) instead of  `...`. That is easier to cascade:&lt;BR /&gt;&lt;BR /&gt;files=$(du -sk $(ls -lrt /data | grep "Oct 4"|awk '{print $9}'))&lt;BR /&gt;&lt;BR /&gt;Your script still has some limitations:&lt;BR /&gt;&lt;BR /&gt;1.) If there are more files created on Oct 4 than can fit on a single command line (run "getconf ARG_MAX" to see the maximum command line length in bytes), your script will fail. But if you already know that the amount of files is relatively small, that is not important.&lt;BR /&gt;&lt;BR /&gt;2.) If there are sub-directories under /data which have been changed on Oct 4, this may skew your results. If there are no subdirectories, not a problem.&lt;BR /&gt;&lt;BR /&gt;3.) The script calculates files dated Oct 4, but Oct 4 _of which year_? If you're sure all files are less than 1 year old, this should not be a problem.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Sun, 04 Oct 2009 10:58:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507376#M365410</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2009-10-04T10:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507377#M365411</link>
      <description>You need to stop using archaic `` and use $() so you can nest them:&lt;BR /&gt;files=$(du -sk $(ls -lrt /data | grep "Oct *4" | awk '{print $9}'))&lt;BR /&gt;&lt;BR /&gt;I'm not sure why you are using du(1) then totaling.  Are you worried about sparse files?&lt;BR /&gt;&lt;BR /&gt;total=$(ll /data | awk '&lt;BR /&gt;BEGIN { total = 0 }&lt;BR /&gt;{ total += $5 }&lt;BR /&gt;END { printf "%1.0f\n", total }')</description>
      <pubDate>Sun, 04 Oct 2009 10:59:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507377#M365411</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-10-04T10:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507378#M365412</link>
      <description>&amp;gt;MK: The above line is equivalent to:&lt;BR /&gt;files=du&lt;BR /&gt;-sk `ls -lrt /data | grep "Oct 4"|awk '{print $9}'`&lt;BR /&gt;&lt;BR /&gt;Almost, they are on the same line.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;You would need to use multiple sets of backquotes, which gets confusing and is prone to errors.&lt;BR /&gt;&lt;BR /&gt;I'm not aware of any way to nest ``, so perhaps the correct statement is "impossible"?&lt;BR /&gt;(You could split them in multiple steps.)&lt;BR /&gt;&lt;BR /&gt;Oops, I lost that "Oct 4" step:&lt;BR /&gt;total=$(ll /data | awk /Oct *4/ '&lt;BR /&gt;BEGIN { total = 0 }&lt;BR /&gt;{ total += $5 }&lt;BR /&gt;END { printf "%1.0f\n", total }')</description>
      <pubDate>Sun, 04 Oct 2009 11:07:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507378#M365412</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-10-04T11:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507379#M365413</link>
      <description>Hi Admins,&lt;BR /&gt;&lt;BR /&gt;Thanx for the replies.Since m new into scripting world, i have limited knowledge on that.&lt;BR /&gt;So Denis, before testing what u suggested i need to refer that commands.&lt;BR /&gt;&lt;BR /&gt;And Duccan ,Thanx for the document.&lt;BR /&gt;And below script i modified.But below error.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;files=`ls -lrt /data | grep "Oct  4"|awk '{print $9}'`&lt;BR /&gt;size=`du -sk $files`&lt;BR /&gt;total=0&lt;BR /&gt;for i in $size&lt;BR /&gt;do&lt;BR /&gt;total=$total+$size&lt;BR /&gt;done&lt;BR /&gt;echo $total&lt;BR /&gt;&lt;BR /&gt;du: FCT_LOANS_CONTRACTS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_ICCF_DETAILS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_INSTRUMENT_TXN_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_DISBURSEMENT_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: DIM_PDC_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: DIM_PERIOD_CODE_STATUS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_ALL_AC_ENTRIES_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: DIM_MIS_DATES_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_LOAN_CONTRACT_LINKAGES_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_LIMIT_UTIL_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: DIM_MIS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_LIMITS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: DIM_MARKET_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_LC_INFO_PARTIES_20091001.DAT.gz: No such file or directory&lt;BR /&gt;du: FCT_LCS_CONTRACTS_20091001.DAT.gz: No such file or directory&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I know you suggested not to use du -sk command.But when i tested the command in shell prompt i got desired output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#du -sk `ls -lrt|grep "Oct  2"|awk '{print $9}'`&lt;BR /&gt;353     FCT_VEHICLE_DETAILS_20091001.DAT.gz&lt;BR /&gt;109     FCT_CONTRACT_STATUS_20091001.DAT.gz&lt;BR /&gt;4090    FCT_CONTRACT_MIS_20091001.DAT.gz&lt;BR /&gt;572     FCT_GL_ACCBREAKUP_20091001.DAT.gz&lt;BR /&gt;5243    DIM_CUSTOMER_20091001.DAT.gz&lt;BR /&gt;14426   FCT_ADV_SCHEDULE_20091001.DAT.gz&lt;BR /&gt;798     FCT_LOANS_CONTRACTS_20091001.DAT.gz&lt;BR /&gt;702     FCT_ICCF_DETAILS_20091001.DAT.gz&lt;BR /&gt;570     FCT_INSTRUMENT_TXN_20091001.DAT.gz&lt;BR /&gt;38      FCT_DISBURSEMENT_20091001.DAT.gz&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Plz suggest on this&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;himacs</description>
      <pubDate>Sun, 04 Oct 2009 11:54:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507379#M365413</guid>
      <dc:creator>himacs</dc:creator>
      <dc:date>2009-10-04T11:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507380#M365414</link>
      <description>&amp;gt;files=`ls -lrt /data | grep "Oct 4" | awk '{print $9}'`&lt;BR /&gt;size=`du -sk $files`&lt;BR /&gt;&lt;BR /&gt;This fails because you are looking at /data but the awk is only getting the filenames, so the du(1) fails.&lt;BR /&gt;&lt;BR /&gt;You'll need to cd to /data, or change to use:&lt;BR /&gt;size_files=$(du -sk $(ls -lrt /data | grep "Oct *4" | awk '{print "/data/" $9}'))&lt;BR /&gt;&lt;BR /&gt;&amp;gt;when I tested the command in shell prompt I got desired output.&lt;BR /&gt;&lt;BR /&gt;Because you were in /data/.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;353 FCT_VEHICLE_DETAILS_20091001.DAT.gz&lt;BR /&gt;&lt;BR /&gt;And you will have to extract field 1 from this to do the summation.</description>
      <pubDate>Sun, 04 Oct 2009 12:20:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507380#M365414</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-10-04T12:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507381#M365415</link>
      <description>Hi admins,&lt;BR /&gt;&lt;BR /&gt;Thanx for ur time.&lt;BR /&gt;&lt;BR /&gt;Below is the script i written which given correct output.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;files=`ls -lrt /data | grep "Oct  2"|awk '{print "/data/" $9}'`&lt;BR /&gt;total=0&lt;BR /&gt;for i in $files&lt;BR /&gt;do&lt;BR /&gt;var1=`du -sk $i|awk '{print $1}'`&lt;BR /&gt;#echo $var1&lt;BR /&gt;total=`expr $total + $var1`&lt;BR /&gt;done&lt;BR /&gt;echo $total&lt;BR /&gt;&lt;BR /&gt;It will work ,if no sub folders exists&lt;BR /&gt;&lt;BR /&gt;Please tell me how to modify the same if subfolder exists&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;himacs&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Oct 2009 14:15:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507381#M365415</guid>
      <dc:creator>himacs</dc:creator>
      <dc:date>2009-10-04T14:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507382#M365416</link>
      <description>Hi Himacs:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Please tell me how to modify the same if subfolder exists&lt;BR /&gt;&lt;BR /&gt;To accommodate this it is easiest to use 'find -type f' to recursively descend subordinate directories below the starting path.&lt;BR /&gt;&lt;BR /&gt;One way to limit what you have to the date of October 4 is to do:&lt;BR /&gt;&lt;BR /&gt;# touch -amt 200910040000 /tmp/ref1&lt;BR /&gt;# touch -amt 200910042359 /tmp/ref2&lt;BR /&gt;&lt;BR /&gt;# find /path -type f \( -newer /tmp/ref1 -a ! -newer /tmp/ref2 \)&lt;BR /&gt;&lt;BR /&gt;This would find only files that have been modified during the 24-hour period of October 4th.  You should read the manpages for 'touch' and for 'find' for a better understanding.&lt;BR /&gt;&lt;BR /&gt;If you don't want to use 'find()' you could use 'ls' recursively (with its '-R' option).  In that case, though, you will have to filter out only files by examining the first character of a long output.  Hint: directories begin with "d" and regular files with "-".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 04 Oct 2009 14:28:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507382#M365416</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-10-04T14:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: script for total files size</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507383#M365417</link>
      <description>himacs,&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I want to get the total size of files dated Oct 4 under /data.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;# cd /data ; ls -l | grep "Oct 4" | awk 'BEGIN {sum=0} {sum+=$5} END {print sum}'&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Sun, 04 Oct 2009 18:06:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-for-total-files-size/m-p/4507383#M365417</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2009-10-04T18:06:55Z</dc:date>
    </item>
  </channel>
</rss>

