<?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: nested variable access in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000089#M98206</link>
    <description>all of those will work a case statement would work also. &lt;BR /&gt;&lt;BR /&gt;case $i in &lt;BR /&gt;   1) &lt;BR /&gt;      echo $1 &lt;BR /&gt;   ;;&lt;BR /&gt;   2) &lt;BR /&gt;      echo $2&lt;BR /&gt;   ;;   &lt;BR /&gt;   3) &lt;BR /&gt;      echo $3&lt;BR /&gt;   ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;However personally I always use getopts to process commandline argument values. &lt;BR /&gt;&lt;BR /&gt;while getopts a:ishv: opt&lt;BR /&gt;do&lt;BR /&gt;   case ${opt} in&lt;BR /&gt;       a) VGM=${OPTARG}&lt;BR /&gt;       ;;&lt;BR /&gt;       i) opt_i=true&lt;BR /&gt;       ;;&lt;BR /&gt;       s) opt_s=true&lt;BR /&gt;       ;;&lt;BR /&gt;       v) VG=${OPTARG}&lt;BR /&gt;       ;;&lt;BR /&gt;       h|*) usage ${0##*/}&lt;BR /&gt;       ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;</description>
    <pubDate>Tue, 29 Aug 2006 08:48:55 GMT</pubDate>
    <dc:creator>Marvin Strong</dc:creator>
    <dc:date>2006-08-29T08:48:55Z</dc:date>
    <item>
      <title>nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000084#M98201</link>
      <description>I am trying to write a shell script, which will print the 1st or 2nd or 3rd commanline argument values based on the value contained in a variable (say i=1 or 2 or 3 respectively)&lt;BR /&gt;&lt;BR /&gt;i=2&lt;BR /&gt;echo \$$i&lt;BR /&gt;&lt;BR /&gt;I tried different options like \$$i, ${$i}, $'$i', $"$i" etc. but nothing is working out.&lt;BR /&gt;&lt;BR /&gt;Please help me do this.</description>
      <pubDate>Tue, 29 Aug 2006 08:09:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000084#M98201</guid>
      <dc:creator>devhariprasad</dc:creator>
      <dc:date>2006-08-29T08:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000085#M98202</link>
      <description>HI,&lt;BR /&gt;have you looked at using shift within a loop ?&lt;BR /&gt;&lt;BR /&gt;"PSEUDO CODE" !&lt;BR /&gt;a=0&lt;BR /&gt;b=$1&lt;BR /&gt;while $a &amp;lt; $b&lt;BR /&gt;do&lt;BR /&gt;shift&lt;BR /&gt;a=a+1&lt;BR /&gt;done&lt;BR /&gt;echo $1</description>
      <pubDate>Tue, 29 Aug 2006 08:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000085#M98202</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-29T08:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000086#M98203</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'd use an array:&lt;BR /&gt;&lt;BR /&gt;set -A args "$@"&lt;BR /&gt;&lt;BR /&gt;echo ${args[$var]}</description>
      <pubDate>Tue, 29 Aug 2006 08:24:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000086#M98203</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-08-29T08:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000087#M98204</link>
      <description>Another option:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo $*| awk -F' ' '{print $$1};'</description>
      <pubDate>Tue, 29 Aug 2006 08:28:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000087#M98204</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-29T08:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000088#M98205</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -A a "${@}"&lt;BR /&gt;i=2&lt;BR /&gt;echo "${a[${i}]}"&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Note that array indexing starts at 0.&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Tue, 29 Aug 2006 08:46:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000088#M98205</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-08-29T08:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000089#M98206</link>
      <description>all of those will work a case statement would work also. &lt;BR /&gt;&lt;BR /&gt;case $i in &lt;BR /&gt;   1) &lt;BR /&gt;      echo $1 &lt;BR /&gt;   ;;&lt;BR /&gt;   2) &lt;BR /&gt;      echo $2&lt;BR /&gt;   ;;   &lt;BR /&gt;   3) &lt;BR /&gt;      echo $3&lt;BR /&gt;   ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;However personally I always use getopts to process commandline argument values. &lt;BR /&gt;&lt;BR /&gt;while getopts a:ishv: opt&lt;BR /&gt;do&lt;BR /&gt;   case ${opt} in&lt;BR /&gt;       a) VGM=${OPTARG}&lt;BR /&gt;       ;;&lt;BR /&gt;       i) opt_i=true&lt;BR /&gt;       ;;&lt;BR /&gt;       s) opt_s=true&lt;BR /&gt;       ;;&lt;BR /&gt;       v) VG=${OPTARG}&lt;BR /&gt;       ;;&lt;BR /&gt;       h|*) usage ${0##*/}&lt;BR /&gt;       ;;&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 29 Aug 2006 08:48:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000089#M98206</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-29T08:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000090#M98207</link>
      <description>Put the following code in your script:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;i=2&lt;BR /&gt;eval echo \$$i</description>
      <pubDate>Tue, 29 Aug 2006 16:22:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000090#M98207</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-08-29T16:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: nested variable access</title>
      <link>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000091#M98208</link>
      <description>The replies were highly useful.</description>
      <pubDate>Tue, 05 Sep 2006 05:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/nested-variable-access/m-p/5000091#M98208</guid>
      <dc:creator>devhariprasad</dc:creator>
      <dc:date>2006-09-05T05:26:54Z</dc:date>
    </item>
  </channel>
</rss>

