<?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: using for loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714705#M791271</link>
    <description>Although ioscan has a limited amount of output, in situations where I don't know the quantity of output I use 'while'.  First redirect the output into a file (as you did) and then read the input from stream 3 (an unused stream) as in this example (working for the other folks answers):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;TOTAL=0&lt;BR /&gt;ioscan -funCdisk 2/dev/null |\&lt;BR /&gt;   grep rdsk|\&lt;BR /&gt;   awk '{print $NF}'\&lt;BR /&gt;   &amp;gt;ioscan.txt&lt;BR /&gt;while read -u3 i; do&lt;BR /&gt;   SIZE=$(diskinfo $i|\&lt;BR /&gt;      grep size|\&lt;BR /&gt;      awk '{ print $2}'\&lt;BR /&gt;      )&lt;BR /&gt;   (( TOTAL = TOTAL + SIZE ))&lt;BR /&gt;done 3&lt;IOSCAN.TXT&gt;&lt;/IOSCAN.TXT&gt;print -- "$TOTAL"&lt;BR /&gt;rm -f ioscan.txt</description>
    <pubDate>Mon, 23 Jan 2006 08:14:30 GMT</pubDate>
    <dc:creator>Jeffrey L. Cooke</dc:creator>
    <dc:date>2006-01-23T08:14:30Z</dc:date>
    <item>
      <title>using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714701#M791267</link>
      <description>how to get the size for more than one disk in one script ..?&lt;BR /&gt;what i did is &lt;BR /&gt;1- ioscan -funCdisk &amp;gt;&amp;gt;f1&lt;BR /&gt;2- cat f1|grep rdsk|awk{'print$2'}&amp;gt;f2&lt;BR /&gt;3- for i in 'cat f2'&lt;BR /&gt;do&lt;BR /&gt;diskinfo $i&amp;gt;&amp;gt;f3&lt;BR /&gt;done&lt;BR /&gt;4- cat f3|grep size&amp;gt;&amp;gt;f4&lt;BR /&gt;5-cat size.out|awk{'print $2'}&amp;gt;f5&lt;BR /&gt;6- f5 output , it contains only numbers , i want to use script to calculate the sum of these number ??&lt;BR /&gt;&lt;BR /&gt;waiting for reply &lt;BR /&gt;thanx</description>
      <pubDate>Sun, 22 Jan 2006 06:01:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714701#M791267</guid>
      <dc:creator>fahad_8</dc:creator>
      <dc:date>2006-01-22T06:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714702#M791268</link>
      <description>Try this :&lt;BR /&gt;&lt;BR /&gt;TOTAL=0&lt;BR /&gt;for i in `ioscan -funCdisk | grep rdsk | awk ' { print $2 } '`&lt;BR /&gt;do&lt;BR /&gt;NUMBER=`diskinfo $i | grep size | awk ' { print $2 } '`&lt;BR /&gt;# that gives you the size of one disk, now add it to the running total&lt;BR /&gt;eval TOTAL=($TOTAL+$NUMBER)&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo $TOTAL&lt;BR /&gt;&lt;BR /&gt;Just check my syntax on the eval statement, I always get that wrong.</description>
      <pubDate>Sun, 22 Jan 2006 08:10:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714702#M791268</guid>
      <dc:creator>Jakes Louw</dc:creator>
      <dc:date>2006-01-22T08:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714703#M791269</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;to sum up:&lt;BR /&gt;# awk '{s += $1}END {print s}' &amp;lt; f5&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Sun, 22 Jan 2006 10:04:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714703#M791269</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-01-22T10:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714704#M791270</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Beware that a simple summation of the values returned by 'diskinfo' by walking the output of 'ioscan', is going to count alternate links (pvlinks) more than once, inflating the amount of disk you think you have.  &lt;BR /&gt;&lt;BR /&gt;Also, if you fail to skip unmounted CD|DVDROM devices, the 'diskinfo' query will hang.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 22 Jan 2006 11:36:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714704#M791270</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-01-22T11:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714705#M791271</link>
      <description>Although ioscan has a limited amount of output, in situations where I don't know the quantity of output I use 'while'.  First redirect the output into a file (as you did) and then read the input from stream 3 (an unused stream) as in this example (working for the other folks answers):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;TOTAL=0&lt;BR /&gt;ioscan -funCdisk 2/dev/null |\&lt;BR /&gt;   grep rdsk|\&lt;BR /&gt;   awk '{print $NF}'\&lt;BR /&gt;   &amp;gt;ioscan.txt&lt;BR /&gt;while read -u3 i; do&lt;BR /&gt;   SIZE=$(diskinfo $i|\&lt;BR /&gt;      grep size|\&lt;BR /&gt;      awk '{ print $2}'\&lt;BR /&gt;      )&lt;BR /&gt;   (( TOTAL = TOTAL + SIZE ))&lt;BR /&gt;done 3&lt;IOSCAN.TXT&gt;&lt;/IOSCAN.TXT&gt;print -- "$TOTAL"&lt;BR /&gt;rm -f ioscan.txt</description>
      <pubDate>Mon, 23 Jan 2006 08:14:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714705#M791271</guid>
      <dc:creator>Jeffrey L. Cooke</dc:creator>
      <dc:date>2006-01-23T08:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: using for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714706#M791272</link>
      <description>for i in `ls /dev/rdsk`&lt;BR /&gt;do&lt;BR /&gt;diskinfo $i|grep -E "describe|size" &amp;gt;&amp;gt; outputfile&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;will do the first part for you.&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Mon, 23 Jan 2006 08:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-for-loop/m-p/3714706#M791272</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2006-01-23T08:26:20Z</dc:date>
    </item>
  </channel>
</rss>

