You don't know Bash: An introduction to Bash arrays


Robert Aboukhalil


As a first step, you want to do a parameter sweep to evaluate how well the pipeline makes use of threads. In turn, this allows us to specify the index to access, e.g., echo ${allThreads[1]} returns the second element of the array. Looping through arrays Although in the examples above we used integer indices in our arrays, let’s consider two occasions when that won’t be the case: First, if we wanted the $i -th element of the array, where $i is a variable containing the index of interest, we can retrieve that element using: echo ${allThreads[$i]} . Some useful syntax But before diving into the code, we need to introduce some more syntax. First, we need to be able to retrieve the output of a Bash command.


Visit Link


Tags: