![]() |
|
|
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 |
| For Loop with Strings as parameters | kadishmj | Shell Programming and Scripting | 6 | 10-06-2008 04:57 AM |
| sed and parameters | scotty_123 | Shell Programming and Scripting | 7 | 03-26-2007 05:22 AM |
| Need Parameters Help. | james2006 | Shell Programming and Scripting | 3 | 06-08-2006 11:46 AM |
| how to get the similar function in while loop or for loop | trynew | Shell Programming and Scripting | 3 | 06-17-2002 12:09 PM |
| tar parameters | kmar | UNIX for Advanced & Expert Users | 4 | 10-23-2001 04:03 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Parameters in loop
Hi, I am trying to write a script which will read inputs form user and process those files, I have issue reading the input parameters in a loop. Following is the script... Code:
I run the script as ./Script.sh 3 table1 table 2 table3
NumberOfTables=$1
let TableCount=1
while [ ${NumberOfTables} -gt 0 ]
do
TableName='$'$TableCount
db2 "runstats on table ${TableName} and indexes all"
let TableCount=TableCount+1
let NumberOfTables=NumberOfTables-1
done
exit 0
here I am not able to capture table1 table2 and table3 in the loop it prints TableName as $1 $2 and $3 but not the names that are given as input. can some one help me on this.... |
|
|||||
|
I do not think you need the TableCount variable, and perhaps a few other things inside your original code. Hopefully, this will put you on your way... Code:
> cat script.sh
#! /bin/bash
NumberOfTables="$#"
let TableCount=1
while [ ${NumberOfTables} -gt 0 ]
do
TableName='$'$TableCount
# db2 "runstats on table ${TableName} and indexes all"
# echo ${TableName}
echo $1
shift
let TableCount=TableCount+1
let NumberOfTables=NumberOfTables-1
done
exit 0
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|