![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem assigning values to variable | finalight | Shell Programming and Scripting | 2 | 05-19-2008 10:56 PM |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 07:38 PM |
| incorrect array values | jhillier | UNIX for Dummies Questions & Answers | 6 | 01-04-2008 04:44 AM |
| assigning values to a variable | trichyselva | UNIX for Dummies Questions & Answers | 3 | 12-14-2007 01:55 AM |
| Problem in assigning values to variables | mohanprabu | Shell Programming and Scripting | 3 | 08-25-2005 04:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Assigning values to an array
The way I've been using arrays currently have been:
Code:
#!/bin/ksh set -A myArray myArray[0]=value1 myArray[1]=value2 myArray[2]=value3 myArray[3]=value4 Code:
myArray=value1 myArray=value2 myArray=value3 myArray=value4 Code:
set -A myArray value1 value2 value3 value4 |
|
|||||
|
Write a function:
Code:
$ cat loadr
#! /usr/bin/ksh
function loadr
{
array[index]=$1
((index=index+1))
return 0
}
index=0
loadr cat
loadr dog
loadr mouse
set | grep array
exit 0
$ ./loadr
array[0]=cat
array[1]=dog
array[2]=mouse
$
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|