Here’s a Bash script that reads Array and prints all the values. Also, you can print the index you want. It’s a simplified script of Arrays. A single value array is called Vector. If it has multiple Values, it’s called Matrix. In the real-time project, you can find word arrays. That means Arrays have words.
Here, I used for loop to get Array elements one by one. I’ve assigned numeric values from 1 to 5 to numbers. Initialized total1 and total2 to ‘0’.
The for loop reads all the elements one after the other. The total1 appends array elements with ‘0’. The let command do computation. It sums up all the numbers and gives a count.
This is a simplified script for arrays.
Result of Array Script