<?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: variable substitution in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469662#M775083</link>
    <description>Tom,&lt;BR /&gt;&lt;BR /&gt;Thanks, but it doesn't fix the problem as I get a,b,c rather than the contents of xxxa, xxxb, xxxc.</description>
    <pubDate>Fri, 01 Dec 2000 16:28:10 GMT</pubDate>
    <dc:creator>Dave Peeke</dc:creator>
    <dc:date>2000-12-01T16:28:10Z</dc:date>
    <item>
      <title>variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469658#M775079</link>
      <description>I am trying in a script to use a variable within a variable and I'm having trouble with the syntax e.g:&lt;BR /&gt;&lt;BR /&gt;xxxa=test1&lt;BR /&gt;xxxb=test2&lt;BR /&gt;xxxc=test3&lt;BR /&gt;for i in a b c&lt;BR /&gt;do&lt;BR /&gt;echo "$xxx$i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;where I want the result to be test1, test2, test3 (not xxxa, xxxb, xxxc). Can anyone help me with the syntax for the echo line please?</description>
      <pubDate>Fri, 01 Dec 2000 16:05:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469658#M775079</guid>
      <dc:creator>Dave Peeke</dc:creator>
      <dc:date>2000-12-01T16:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469659#M775080</link>
      <description>I've done a similar test:&lt;BR /&gt;&lt;BR /&gt;a=test1&lt;BR /&gt;b=test2&lt;BR /&gt;c=test3&lt;BR /&gt;for i in $a $b $c&lt;BR /&gt;do&lt;BR /&gt;echo "$i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The variables you should specify with $xxxa etc.&lt;BR /&gt;&lt;BR /&gt;Is this what you want?</description>
      <pubDate>Fri, 01 Dec 2000 16:11:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469659#M775080</guid>
      <dc:creator>Darrel Louis</dc:creator>
      <dc:date>2000-12-01T16:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469660#M775081</link>
      <description>Darrel,&lt;BR /&gt;&lt;BR /&gt;Not quite as I don't want to specify the whole variable in the for statement. The previously assigned variables need to be longer and I will actually be using a number to reference them in a loop i.e. disk1 disk2 disk3 etc and the loop count will be used for the number i.e. for i in 1 2 3 4.</description>
      <pubDate>Fri, 01 Dec 2000 16:21:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469660#M775081</guid>
      <dc:creator>Dave Peeke</dc:creator>
      <dc:date>2000-12-01T16:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469661#M775082</link>
      <description>Try putting curly braces around the variable name.  Required if the variable name adjoins additional text.  Such as:&lt;BR /&gt;&lt;BR /&gt;echo "${xxx}${i}" &lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2000 16:22:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469661#M775082</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2000-12-01T16:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469662#M775083</link>
      <description>Tom,&lt;BR /&gt;&lt;BR /&gt;Thanks, but it doesn't fix the problem as I get a,b,c rather than the contents of xxxa, xxxb, xxxc.</description>
      <pubDate>Fri, 01 Dec 2000 16:28:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469662#M775083</guid>
      <dc:creator>Dave Peeke</dc:creator>
      <dc:date>2000-12-01T16:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469663#M775084</link>
      <description>This should work:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;xxxa="test 1"&lt;BR /&gt;xxxb="test 2"&lt;BR /&gt;xxxc="test 3"&lt;BR /&gt;&lt;BR /&gt;for I in a b c&lt;BR /&gt;do&lt;BR /&gt;   eval "echo \$xxx$I"&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2000 17:40:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469663#M775084</guid>
      <dc:creator>Kenneth Platz</dc:creator>
      <dc:date>2000-12-01T17:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469664#M775085</link>
      <description>I dont think you can echo a variable that is itself an echo of another, so I dont see any solution except Darrels,which mean you need a step between:&lt;BR /&gt;xxxa=test1&lt;BR /&gt;xxxb=test2&lt;BR /&gt;xxxc=test3&lt;BR /&gt;&lt;BR /&gt;a=$xxxa&lt;BR /&gt;b=$xxxb&lt;BR /&gt;c=$xxxc&lt;BR /&gt;for i in $a $b $c&lt;BR /&gt;do&lt;BR /&gt;echo "$i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;BR /&gt;&lt;BR /&gt;Victor&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Dec 2000 17:45:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469664#M775085</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-12-01T17:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469665#M775086</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Assign the variable as follows:&lt;BR /&gt;&lt;BR /&gt;xxx[1]=tiger ;  xxx[2]=lion ;  xxx[3]=cat&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you assign as above then the following would do the job:&lt;BR /&gt;&lt;BR /&gt;for i in ${xxx[@]} ; do&lt;BR /&gt;&lt;BR /&gt;  echo $i&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Above should display:&lt;BR /&gt;tiger&lt;BR /&gt;lion&lt;BR /&gt;cat&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best of luck,&lt;BR /&gt;&lt;BR /&gt;Pramod</description>
      <pubDate>Fri, 01 Dec 2000 19:00:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469665#M775086</guid>
      <dc:creator>Pramod_4</dc:creator>
      <dc:date>2000-12-01T19:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469666#M775087</link>
      <description>I agree, this case seems quite appropriate for an array variable.  You can even set teh variables easily using set -A</description>
      <pubDate>Fri, 01 Dec 2000 19:13:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469666#M775087</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2000-12-01T19:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: variable substitution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469667#M775088</link>
      <description>Not that your problem is not fixed already.....Some good things were posted.  Another thing I do occasionally is use a little used command "eval".  I.E.&lt;BR /&gt;xxxa=1&lt;BR /&gt;xxxb=2&lt;BR /&gt;xxxc=3&lt;BR /&gt;for i in $a $b $c ; do&lt;BR /&gt;eval echo "\$xxx$i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The eval tells the shell to expand all of the variables prior to excecuting the "echo".&lt;BR /&gt;This is why Kenneths example works!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon</description>
      <pubDate>Sat, 02 Dec 2000 12:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/variable-substitution/m-p/2469667#M775088</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2000-12-02T12:27:59Z</dc:date>
    </item>
  </channel>
</rss>

