Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a specifik element in an array

Status
Not open for further replies.

Larshg

Programmer
Mar 1, 2001
187
DK
Hi

I have an array
set -A zerros 0 0 0 0

What is the command to update the 2. carater in the array - to ex 1

So that my array would look something like this
before
0 0 0 0

command xxxx${zerros[$2]}=1


after
0 1 0 0

Thanks

Larshg
 
zerros[1]=1

indice starts at 0

/home/jp> set -A array 0 1 2 3
/home/jp> echo ${array[*]}
0 1 2 3
/home/jp> echo ${array[2]}
2
/home/jp> array[2]=222
/home/jp> echo ${array[*]}
0 1 222 3
/home/jp>


Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top