<?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 arrays in ksh script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177614#M718157</link>
    <description>This is how arrays are supposed to be used.&lt;BR /&gt; &lt;BR /&gt;colour[0]=red&lt;BR /&gt;colour[1]=blue&lt;BR /&gt;colour[2]=red&lt;BR /&gt;colour[3]=green&lt;BR /&gt;colour[4]=green&lt;BR /&gt;colour[5]=blue&lt;BR /&gt;colour[6]=yellow&lt;BR /&gt;colour[7]=cyan&lt;BR /&gt;colour[8]=red&lt;BR /&gt;colour[9]=blue&lt;BR /&gt;&lt;BR /&gt;echo ${colour[2]}&lt;BR /&gt; &lt;BR /&gt;That will output "red"</description>
    <pubDate>Thu, 29 Jan 2004 10:40:52 GMT</pubDate>
    <dc:creator>Mark Grant</dc:creator>
    <dc:date>2004-01-29T10:40:52Z</dc:date>
    <item>
      <title>Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177613#M718156</link>
      <description>Hi,&lt;BR /&gt;I'm trying to use arrays in a ksh script.&lt;BR /&gt;I'm implementing an example found on the forum.&lt;BR /&gt;But it doesn't work and I can't see why !&lt;BR /&gt;the commands are :&lt;BR /&gt;DAYS[0]=Mon&lt;BR /&gt;DAYS[1]=Tue&lt;BR /&gt;DAYS[2]=Wed&lt;BR /&gt;print $DAYS&lt;BR /&gt;print $DAYS[0]&lt;BR /&gt;print $DAYS[1]&lt;BR /&gt;print $DAYS[2]&lt;BR /&gt;&lt;BR /&gt;and the result is :&lt;BR /&gt;DAYS:  not found&lt;BR /&gt;DAYS:  not found&lt;BR /&gt;DAYS:  not found&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Where is the problem ? (Am I using a wrong ksh ?)&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Jan 2004 10:36:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177613#M718156</guid>
      <dc:creator>Lorenzo Meneguzzi</dc:creator>
      <dc:date>2004-01-29T10:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177614#M718157</link>
      <description>This is how arrays are supposed to be used.&lt;BR /&gt; &lt;BR /&gt;colour[0]=red&lt;BR /&gt;colour[1]=blue&lt;BR /&gt;colour[2]=red&lt;BR /&gt;colour[3]=green&lt;BR /&gt;colour[4]=green&lt;BR /&gt;colour[5]=blue&lt;BR /&gt;colour[6]=yellow&lt;BR /&gt;colour[7]=cyan&lt;BR /&gt;colour[8]=red&lt;BR /&gt;colour[9]=blue&lt;BR /&gt;&lt;BR /&gt;echo ${colour[2]}&lt;BR /&gt; &lt;BR /&gt;That will output "red"</description>
      <pubDate>Thu, 29 Jan 2004 10:40:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177614#M718157</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-01-29T10:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177615#M718158</link>
      <description>Although your example hasn't come out in the example you posted, I think it looks like you have missed outh the "${" and "}" around the whole variable thing.</description>
      <pubDate>Thu, 29 Jan 2004 10:44:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177615#M718158</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-01-29T10:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177616#M718159</link>
      <description>This is one of those times when discipline counts. ALWAYS enclose shell variables in braces and you will have no problems.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;DAYS[0]="Mon"&lt;BR /&gt;DAYS[1]="Tue"&lt;BR /&gt;DAYS[2]="Wed"&lt;BR /&gt;&lt;BR /&gt;#Now try this:&lt;BR /&gt;print $DAYS[1]&lt;BR /&gt;print ${DAYS[1]}&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Jan 2004 10:47:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177616#M718159</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-29T10:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177617#M718160</link>
      <description>Here's a re-write of Mark's script:&lt;BR /&gt;colour[0]=red&lt;BR /&gt;colour[1]=blue&lt;BR /&gt;colour[2]=red&lt;BR /&gt;colour[3]=green&lt;BR /&gt;colour[4]=green&lt;BR /&gt;colour[5]=blue&lt;BR /&gt;colour[6]=yellow&lt;BR /&gt;colour[7]=cyan&lt;BR /&gt;colour[8]=red&lt;BR /&gt;colour[9]=blue&lt;BR /&gt;COUNTER=0&lt;BR /&gt;while test "$COUNTER" -lt "10"&lt;BR /&gt;do&lt;BR /&gt;        echo $COUNTER ${colour[$COUNTER]}&lt;BR /&gt;        (( COUNTER = "$COUNTER" + "1" ))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You can see the syntax of how the subscript works then.  &lt;BR /&gt;</description>
      <pubDate>Thu, 29 Jan 2004 11:02:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177617#M718160</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2004-01-29T11:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177618#M718161</link>
      <description>Thanks.&lt;BR /&gt;It's MUCH EASIER this way !</description>
      <pubDate>Thu, 29 Jan 2004 11:30:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177618#M718161</guid>
      <dc:creator>Lorenzo Meneguzzi</dc:creator>
      <dc:date>2004-01-29T11:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays in ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177619#M718162</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It's easy to get confused with Arrays. Following script may give you little more information on ARRAYs.&lt;BR /&gt;&lt;BR /&gt;set -A ARRAY&lt;BR /&gt;&lt;BR /&gt;ARRAY[0]="elem 1 "&lt;BR /&gt;ARRAY[1]="elem 2"&lt;BR /&gt;ARRAY[2]="elem 3"&lt;BR /&gt;ARRAY[3]="elem 4"&lt;BR /&gt;ARRAY[4]="elem 5"&lt;BR /&gt;&lt;BR /&gt;typeset -i num_elms=${#ARRAY[@]}&lt;BR /&gt;typeset -i count=0&lt;BR /&gt;&lt;BR /&gt;while [ $count -lt num_elms ]&lt;BR /&gt;do&lt;BR /&gt;echo "ARRAY[$count] is ${ARRAY[$count]}"&lt;BR /&gt;(( count = $count + 1 ))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 29 Jan 2004 12:06:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-arrays-in-ksh-script/m-p/3177619#M718162</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-01-29T12:06:48Z</dc:date>
    </item>
  </channel>
</rss>

