![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| incorrect array values | jhillier | UNIX for Dummies Questions & Answers | 6 | 01-04-2008 04:44 AM |
| printing all array values using dbx 7.2.1 | JamesGoh | High Level Programming | 1 | 12-18-2007 04:07 PM |
| to assign cut values to an array | Syms | UNIX for Dummies Questions & Answers | 6 | 10-29-2007 06:42 AM |
| Assigning values to an array | yongho | UNIX for Dummies Questions & Answers | 4 | 07-13-2005 08:49 PM |
| array values in a command | eeisken | Shell Programming and Scripting | 3 | 06-22-2005 04:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to use array values after the loop.
- I m retreving values from database and wish to use those values later in my shell script. I m placing these values in an array da_data but outside loop array is empty.Problem is its treating array as local inside loop hence array is empty outside loop.
Plz go through the script and suggest how to use array values after the loop. declare -a da_data count=0 cat $LOAD_DA_FILE | \ while read da_name do da_data[count]=`$ORACLE_HOME/bin/sqlplus -s username/password@instance << EOF set heading off set feed off select start_date from table where derive_name='$da_name'; EXIT EOF` count=`expr $count + 1` echo ${da_data[count-1]} # displaying array value done echo -n "Elements Of array : " echo ${da_data[@]} # array empty - thanks in advance |
|
||||
|
Try this instead:
Code:
declare -a da_data
count=0
while read da_name
do
da_data[count]=`$ORACLE_HOME/bin/sqlplus -s username/password@instance << EOF
set heading off
set feed off
select start_date from table where derive_name='$da_name';
EXIT
EOF`
count=`expr $count + 1`
echo ${da_data[count-1]} # displaying array value
done < $LOAD_DA_FILE
echo -n "Elements Of array : "
echo ${da_data[@]} # array empty
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|