<?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 Newbie Array Question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373628#M713499</link>
    <description>I want to create two arrays.  I've got the following code in place:&lt;BR /&gt;&lt;BR /&gt;cat /tmp/thrdsts.txt | while line=`line`&lt;BR /&gt;   do&lt;BR /&gt;      thread=`echo $line | awk '{print $1}'`&lt;BR /&gt;      status=`echo $line | awk '{print $2}'`&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;I'm hoping this will get the assigning part done(am I right?).  Next question is how do I reference these.  I've trien echo $thread[1], but all I get is [1].&lt;BR /&gt;&lt;BR /&gt;I'm using what I think is bourne shell /bin/sh, on HP-UX 11.0&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Scott</description>
    <pubDate>Tue, 07 Sep 2004 10:04:50 GMT</pubDate>
    <dc:creator>Scott Frye_1</dc:creator>
    <dc:date>2004-09-07T10:04:50Z</dc:date>
    <item>
      <title>Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373628#M713499</link>
      <description>I want to create two arrays.  I've got the following code in place:&lt;BR /&gt;&lt;BR /&gt;cat /tmp/thrdsts.txt | while line=`line`&lt;BR /&gt;   do&lt;BR /&gt;      thread=`echo $line | awk '{print $1}'`&lt;BR /&gt;      status=`echo $line | awk '{print $2}'`&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;I'm hoping this will get the assigning part done(am I right?).  Next question is how do I reference these.  I've trien echo $thread[1], but all I get is [1].&lt;BR /&gt;&lt;BR /&gt;I'm using what I think is bourne shell /bin/sh, on HP-UX 11.0&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Scott</description>
      <pubDate>Tue, 07 Sep 2004 10:04:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373628#M713499</guid>
      <dc:creator>Scott Frye_1</dc:creator>
      <dc:date>2004-09-07T10:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373629#M713500</link>
      <description>Don't know if this helps.&lt;BR /&gt; &lt;BR /&gt;The standard HP-UX Bourne Shell is a Posix shell (see "man sh-posix", especially the section on arrays)&lt;BR /&gt; &lt;BR /&gt;Initilisation and value assignment can take place in the same line.&lt;BR /&gt; &lt;BR /&gt;e.g.&lt;BR /&gt; &lt;BR /&gt;# set -A array tic tac toe&lt;BR /&gt; &lt;BR /&gt;# echo ${array[*]}&lt;BR /&gt;tic tac toe&lt;BR /&gt; &lt;BR /&gt;or you can assign elements individually&lt;BR /&gt; &lt;BR /&gt;e.g.&lt;BR /&gt;  &lt;BR /&gt;# array[${#array[*]}]=donald&lt;BR /&gt; &lt;BR /&gt;# echo ${array[*]}          &lt;BR /&gt;tic tac toe donald&lt;BR /&gt; &lt;BR /&gt;n.b. just insert the correct index in the square brackets, the ${#array[*]} construct derefernces the dimension of the array, thus the right index for the next element&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 10:20:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373629#M713500</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-09-07T10:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373630#M713501</link>
      <description>Hi Scott,&lt;BR /&gt;&lt;BR /&gt;One way to do it in the POSIX shell is like this:&lt;BR /&gt;&lt;BR /&gt;set -A thread $(awk '{print $1} /tmp/thrdsts.txt)&lt;BR /&gt;set -A status $(awk '{print $2} /tmp/thrdsts.txt)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo "thread[1] is ${thread[1]}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can use the 'set -A' like above to declare your variable as an array and set the elements of the array to the list provided by the next argument.&lt;BR /&gt;&lt;BR /&gt;In the POSIX shell you are limited to 1024 elements in your array, so if you have a large file you might want to consider using something like Perl.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 10:21:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373630#M713501</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2004-09-07T10:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373631#M713502</link>
      <description>CNT=0&lt;BR /&gt;cat /tmp/thrdsts.txt | while line=`line`&lt;BR /&gt;do&lt;BR /&gt;thread_$CNT=`echo $line | awk '{print $1}'`&lt;BR /&gt;status_$CNT=`echo $line | awk '{print $2}'`&lt;BR /&gt;CNT=`expr $CNT + 1`&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 10:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373631#M713502</guid>
      <dc:creator>Michael_356</dc:creator>
      <dc:date>2004-09-07T10:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373632#M713503</link>
      <description>Addendum, as for the part of referncing elements: &lt;BR /&gt; &lt;BR /&gt;# i=0; while [ $i -lt ${#array[*]} ];do echo ${array[$i]};((i+=1));done&lt;BR /&gt;tic&lt;BR /&gt;tac&lt;BR /&gt;toe&lt;BR /&gt;donald&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 10:23:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373632#M713503</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-09-07T10:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373633#M713504</link>
      <description>You should use this instead :&lt;BR /&gt;let count=1&lt;BR /&gt;cat /tmp/thrdsts.txt | while line=`line`&lt;BR /&gt;do&lt;BR /&gt;thread[$i]=`echo $line | awk '{print $1}'`&lt;BR /&gt;status[$i]=`echo $line | awk '{print $2}'`&lt;BR /&gt;let i=i+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;then you will refer to arrays with :&lt;BR /&gt;${thread[$n]}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 10:26:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373633#M713504</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-09-07T10:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie Array Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373634#M713505</link>
      <description>Thank you all very much.  Some of these methods I tried and couldn't get to work easily.  My favorite and (in my opinion) the cleanest was &lt;BR /&gt;set -A thread $(awk '{print $1}' /tmp/thrdsts.txt)&lt;BR /&gt;set -A status $(awk '{print $2}' /tmp/thrdsts.txt)&lt;BR /&gt;&lt;BR /&gt;I like it because there is no need for a while.&lt;BR /&gt;&lt;BR /&gt;Thanks to all who replied.</description>
      <pubDate>Tue, 07 Sep 2004 10:34:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/newbie-array-question/m-p/3373634#M713505</guid>
      <dc:creator>Scott Frye_1</dc:creator>
      <dc:date>2004-09-07T10:34:17Z</dc:date>
    </item>
  </channel>
</rss>

