The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Enviornment Variable in B shell (I call it nested variable) princelinux Shell Programming and Scripting 4 07-02-2008 02:35 AM
awk computed variable names craig06y Shell Programming and Scripting 4 02-05-2008 01:50 PM
Can we pass array with call by value in function ranjithpr Shell Programming and Scripting 1 12-26-2007 12:22 PM
Variable names Bab00shka UNIX for Dummies Questions & Answers 2 11-11-2005 11:45 AM
Variable names Bab00shka Shell Programming and Scripting 4 08-15-2002 12:00 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-19-2009
vockleya vockleya is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 8
Variable names within array call

I am trying to write a piece of code that will call a value from an array. There are multiple arrays that I need to call data from. Only one array needs to be used based on the step within the program. The arrays have the names "cue_0", "cue_1", and so on.

I can't figure out how to call a value from an array based on the array number (the one after the underscore) and the position within the array. I have been able to get it working when not using a variable in the array name, but putting a variable within the array name makes it stop working. I get an error that says "bad substitution" about the line of code noted below when I replace the "0" with a variable.

The code below is the part of my script that I am having trouble with. Any help would be greatly appreciated.


Code:
for i in `seq 0 23`; do
     let position=i*4+9
     tput cup 1 $position
     case ${cue_0[$i]} in      # I want to replace the "0" in this line with a variable"
          0) printf "off" ;;
          1) printf "on" ;;
     esac
done

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0