Operating System - HP-UX
1748166 Members
3799 Online
108758 Solutions
New Discussion юеВ

Re: posix-sh - number of elements in an array

 
SOLVED
Go to solution
Scott Williams_5
Frequent Advisor

posix-sh - number of elements in an array

Using posix shell, how do I determine how many elements are in an array.

ex:
set -A arr $(print "file1 file2 file3 file4").

I need to know that there are four elements in this array.

Thanks!
2 REPLIES 2
Sundar_7
Honored Contributor
Solution

Re: posix-sh - number of elements in an array

Try this

echo "Number of elements in the array: ${#arr[*]}"


Learn What to do ,How to do and more importantly When to do ?
Scott Williams_5
Frequent Advisor

Re: posix-sh - number of elements in an array

Bingo...I think I tried every variation on the placement of the "#", but couldn't get it right. Thanks for help.