Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> How to Zero a Loop of Declared Arrays
Valjean
post Feb 26 2016, 05:00 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 15
Joined: 22-February 16
Member No.: 19,047



The challenge I am facing is how to make a do loop which declares a bunch of arrays and then zeros them. I am struggling with this for the same reasons as described in a previous post (http://www.linuxhelp.net/forums/index.php?showtopic=11016); however, I believe the solution for that particular case is different from this particular case.

In pseudo-code, I want to declare a bunch of arrays

do i, max_i
do j, max_j
declare temp_$i[$j]
temp_$i[$j]=0
end do
end do

I can declare the arrays in a loop, but how can I zero them? In this case, I can cheat in that I know itís always a 1x8 array, but I still do not know how to zero it.

while [ $j -lt $helixmax ]
do
while [ $i -le $directory ]
do
declare -a temp1_$i
temp1_$i=(0 0 0 0 0 0 0 0 )
#temp_$i[$j]=0
#temp_$i[$j]=$test-${average[$j]}
i=$((i+1))
done
i=1
j=$((j+1))
done
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
michaelk
post Feb 27 2016, 08:11 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,797
Joined: 23-January 03
Member No.: 360



Must be.
Go to the top of the page
 
+Quote Post

Posts in this topic
- Valjean   How to Zero a Loop of Declared Arrays   Feb 26 2016, 05:00 PM
- - michaelk   Try this: #!/bin/bash for (( i=0; i<=8; i+...   Feb 26 2016, 07:53 PM
|- - Valjean   QUOTE (michaelk @ Feb 26 2016, 07:53 PM) ...   Feb 27 2016, 10:00 AM
- - michaelk   No problem.   Feb 27 2016, 11:20 AM
|- - Valjean   QUOTE (michaelk @ Feb 27 2016, 11:20 AM) ...   Feb 27 2016, 12:42 PM
- - michaelk   Not sure since you left off the initialization of ...   Feb 27 2016, 04:54 PM
|- - Valjean   QUOTE (michaelk @ Feb 27 2016, 04:54 PM) ...   Feb 27 2016, 05:49 PM
- - michaelk   Must be.   Feb 27 2016, 08:11 PM
|- - Valjean   QUOTE (michaelk @ Feb 27 2016, 08:11 PM) ...   Feb 27 2016, 09:44 PM
- - michaelk   Yep, that is it...   Feb 28 2016, 06:24 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st October 2017 - 09:54 PM