![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| How to assign a variable value to array? | balamv | Shell Programming and Scripting | 2 | 06-06-2008 04:33 AM |
| How to declare an array to take more than 10,000 characters | pinky | Shell Programming and Scripting | 0 | 01-15-2008 10:38 PM |
| How to declare global variables for shell script | risshanth | UNIX for Dummies Questions & Answers | 2 | 10-31-2007 03:27 AM |
| to assign cut values to an array | Syms | UNIX for Dummies Questions & Answers | 6 | 10-29-2007 06:42 AM |
| Loop counter variable display | lifespan | Shell Programming and Scripting | 2 | 03-28-2006 07:21 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
declare, assign variables using array, counter, loop
using bash Tru64...
converting DCL to shell... any tips to make this work would be greatly appreciated. Below is my failed attempt to assign command line input to variables by first declaring an array. I use a counter to create unique variables in a loop through the array. I need to call the newly created variables in functions, hence the export. When I run the script I receive the following error... ./newfile1.shl: param1=1: command not found ./newfile1.shl: param2=2: command not found ./newfile1.shl: param3=3: command not found ./newfile1.shl: param4=4: command not found ./newfile1.shl: param5=5: command not found #!/bin/bash LIMIT=6 PARAM="$1 $2 $3 $4 $5" COUNTER=1 while [ $COUNTER -lt "$LIMIT" ]; do for n in ${PARAM[@]} do param$COUNTER=`echo $n` export param$COUNTER let COUNTER=COUNTER+1 done done echo $param1 echo $param2 echo $param3 echo $param4 echo $param5 |
| Bookmarks |
| Tags |
| bash, bash eval, eval |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|