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
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

 
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 08-06-2004
egkumpe egkumpe is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 2
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
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 12:05 PM.


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