Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th June 2008, 15:34
niekshas niekshas is offline
Junior Member
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default bash script -->> arrays, Indirect Variable References--->> help :)

#well ihawe something like this

Array=(first second)

firstoption=(one two)

secondoption=(11 22)

#now i'm reading like this

For segment in "${Array[@]}"; do
x=$segment"option" #i'm geing something like firstoption
eval t=\${$x[@]} #I hope that t will be array
For opt in "${t[@]}"
echo opt
done
done

###############

well i hope read like all options... but cant... couse t hawe only one value "one two" or "11 22 "
i cnow thats LAME so i'm asking... how i can improve this script ???
Reply With Quote
Sponsored Links
  #2  
Old 30th June 2008, 12:35
burschik burschik is offline
Junior Member
 
Join Date: May 2008
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
Default Do you mean

HTML Code:
Array=(first second)

firstoption=(one two)

secondoption=(11 22)

#now i'm reading like this

for segment in "${Array[@]}"; do
    x=$segment"option" 
    eval t=\${$x[@]} 
    for opt in ${t}; do
        echo $opt
    done
done
Reply With Quote
  #3  
Old 1st July 2008, 13:18
burschik burschik is offline
Junior Member
 
Join Date: May 2008
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default Come to think of it, you may mean this

HTML Code:
Array=(first second)

firstoption=(one two)

secondoption=(11 22)

for segment in ${Array[@]}; do
    x=${segment}option
    eval t=(\${$x[@]})
    for opt in ${t[@]}; do
        echo $opt
    done
done
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
env variable mac address script problems schris403 Programming/Scripts 2 3rd August 2009 23:35
i am having some problem ? cobro Installation/Configuration 20 30th April 2008 16:26
Cannot log onto pop3 server Debian Etch Perfect Server docean Installation/Configuration 2 19th March 2008 00:23
https protocol stops page load tjd General 7 18th November 2007 18:06
req: Bash / Script to auto kill PID if it's needed.... edge Programming/Scripts 8 13th March 2006 23:31


All times are GMT +2. The time now is 02:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.