Shell Script to print contents of an array
Program
#!/bin/bash
echo "Enter the size of array"
read size
echo "Enter $size elements"
for((i=0;i<size;i++))
do
read arr[$i]
done
echo "Contents of array:"
for((i=0;i<size;i++))
do
echo ${arr[$i]}
done
Output
$ sh print-contents-of-array.sh
Enter the size of array
6
Enter 6 elements
12
43
56
78
23
56
Contents of array:
12
43
56
78
23
56