This is a Simple usage Example of a 'while' loop in Shell Scripting.
Program Code:
#!/bin/bash
#Printing the Contents of Array!
declare -a Unix=('Debain' 'Redhat' 'Ubuntu' 'Suse' 'Fedora');
echo " Number of Elements in an Array: ${#Unix[@]}"
#Method 1
echo " Printing Contents of Array at one Shot : ${Unix[@]}"
#Method2
echo " Printing Contents of Array at one Shot : ${Unix[*]}"
echo " Printing Values of Array using for loop..."
for ((i=0; i < ${#Unix[@]}; i++))
do
echo " ${Unix[$i]}"
done
Program Output:
Post a Comment