Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of array variables.

Status
Not open for further replies.

gawker

Programmer
Feb 21, 2002
34
US
Hi,

If an array has been created in an awk process via the split command, is there a variable that reports on the number of array entries?

I can get the information by reading the array with "while", but figure there must be a more direct way of getting the value.

Thanks!

[pacman]

gawker
 
split returns the number of array elements it creates, so you just need something like

n1 = split($0,a)

and n1 would be the number array elements created. CaKiwi
 

split (s,a[,fs])
Split the string s into array elements a[1],
a[2],..., a[n], and return n. The
separation will be done with the extended
regular expression fs or with the field
separator FS if fs is not given.

n = split (ENVIRON["PATH"], path, ":")
for (i = 1; i <= n; ++i)
print path
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top