An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Wednesday, December 3, 2008

Shell Scripting #0002 - Length of an Array

No comments :
Keywords: Linux, Shell Scripting, Scripts, BASH

Shell Scripting #0002 - Length of an Array:

Following is the code snippet to find the length of an Array:

#!/bin/sh

array=(red green blue yellow magenta)
len=${#array[*]}

echo "The array has $len members. They are:"
i=0
while [ $i -lt $len ]; do
echo "$i: ${array[$i]}"
let i++
done

Keywords: Linux, Shell Scripting, Scripts, BASH

Featured Blog Topics:

No comments :