<?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: Arrays in shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145341#M801764</link>
    <description>arr[0]=value1&lt;BR /&gt;arr[1]=value2&lt;BR /&gt;arr[2]=value3&lt;BR /&gt;&lt;BR /&gt;var=value3&lt;BR /&gt;typeset -i10 I=0&lt;BR /&gt;while [[ ${I} -lt ${#arr[*]} ]]&lt;BR /&gt;do&lt;BR /&gt;  if [[ "${arr[${I}]}" = "${var}" ]]&lt;BR /&gt;    then&lt;BR /&gt;      echo "Do something"&lt;BR /&gt;    fi&lt;BR /&gt;  (( I += 1 ))&lt;BR /&gt;done</description>
    <pubDate>Mon, 15 Dec 2003 18:01:44 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2003-12-15T18:01:44Z</dc:date>
    <item>
      <title>Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145340#M801763</link>
      <description>Guys,&lt;BR /&gt;&lt;BR /&gt;I want to put some values in a array in my script and check them for a condition.&lt;BR /&gt;Ex.&lt;BR /&gt;***************&lt;BR /&gt;arr[0]=value1&lt;BR /&gt;arr[1]=value2&lt;BR /&gt;arr[2]=value3&lt;BR /&gt;&lt;BR /&gt;var=value3&lt;BR /&gt;&lt;BR /&gt;while(arr.length)&lt;BR /&gt;if ($var == arr[x])&lt;BR /&gt;then&lt;BR /&gt;do somthing&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;***************&lt;BR /&gt;&lt;BR /&gt;Can someone help me!&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Dec 2003 17:50:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145340#M801763</guid>
      <dc:creator>dude70_1</dc:creator>
      <dc:date>2003-12-15T17:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145341#M801764</link>
      <description>arr[0]=value1&lt;BR /&gt;arr[1]=value2&lt;BR /&gt;arr[2]=value3&lt;BR /&gt;&lt;BR /&gt;var=value3&lt;BR /&gt;typeset -i10 I=0&lt;BR /&gt;while [[ ${I} -lt ${#arr[*]} ]]&lt;BR /&gt;do&lt;BR /&gt;  if [[ "${arr[${I}]}" = "${var}" ]]&lt;BR /&gt;    then&lt;BR /&gt;      echo "Do something"&lt;BR /&gt;    fi&lt;BR /&gt;  (( I += 1 ))&lt;BR /&gt;done</description>
      <pubDate>Mon, 15 Dec 2003 18:01:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145341#M801764</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-12-15T18:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145342#M801765</link>
      <description>Hi Stephen,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply. Can you explain few more things. How do I put the values in the array and  what does "typeset -i10 I=0 " this line do. Is it min and max values of array? &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Dec 2003 18:08:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145342#M801765</guid>
      <dc:creator>dude70_1</dc:creator>
      <dc:date>2003-12-15T18:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145343#M801766</link>
      <description>Hi dude70,&lt;BR /&gt;&lt;BR /&gt;the typeset defines the variable l as 10 character integer and initializes it with zero. The index of a one dimensional array is limited to 1023. The assignment, you choose is ok. Where you get your data from, is up to you.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Dec 2003 18:21:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145343#M801766</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-12-15T18:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145344#M801767</link>
      <description>Thanks Mike!&lt;BR /&gt;I am reading the values from a file.</description>
      <pubDate>Mon, 15 Dec 2003 18:34:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145344#M801767</guid>
      <dc:creator>dude70_1</dc:creator>
      <dc:date>2003-12-15T18:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145345#M801768</link>
      <description>Actually typeset -i10 I=0 declares I to be a base 10 integer and assigns its initial value at zero.&lt;BR /&gt;&lt;BR /&gt;To read the values into a file is also quite simple:&lt;BR /&gt;&lt;BR /&gt;typeset -i10 KNT=0&lt;BR /&gt;INFILE="/var/tmp/myfile"&lt;BR /&gt;&lt;BR /&gt;cat ${INFILE} | while read arr[${KNT}]&lt;BR /&gt;do&lt;BR /&gt;  (( KNT += 1))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;var="Two"&lt;BR /&gt;typeset -i10 I=0&lt;BR /&gt;while [[ ${I} -lt ${KNT} ]]&lt;BR /&gt;do&lt;BR /&gt;if [[ "${arr[${I}]}" = "${var}" ]]&lt;BR /&gt;then&lt;BR /&gt;echo "Do something"&lt;BR /&gt;fi&lt;BR /&gt;(( I += 1 ))&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Assignments to array elements are just like assignments to a simple variable.&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Dec 2003 18:55:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/arrays-in-shell/m-p/3145345#M801768</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-12-15T18:55:11Z</dc:date>
    </item>
  </channel>
</rss>

