27 lines
499 B
Bash
27 lines
499 B
Bash
#!/bin/bash
|
|
|
|
test=($(find /Library/Java/JavaVirtualMachines -type d -name '*.jdk' -prune -print))
|
|
echo ${test[@]}
|
|
|
|
for i in "${test[@]}"; do
|
|
echo $i
|
|
done
|
|
|
|
https://www.geeksforgeeks.org/array-basics-shell-scripting-set-2-using-loops/
|
|
|
|
# !/bin/bash
|
|
# To declare static Array
|
|
arr=(1 12 31 4 5)
|
|
i=0
|
|
|
|
# Loop upto size of array
|
|
# starting from index, i=0
|
|
while [ $i -lt ${#arr[@]} ]
|
|
do
|
|
# To print index, ith
|
|
# element
|
|
echo ${arr[$i]}
|
|
|
|
# Increment the i = i + 1
|
|
i=`expr $i + 1`
|
|
done |