And here's an awk approach:
$ awk -F'[ ,]' -v RS= '{n=split($0,a,"\n"); print $2,n-1}' file [email protected] 1 [email protected] 2 [email protected] 0 [email protected] 1 Explanation
-F'[ ,]': set the field separator to space or comma.-v RS=: enables paragraph mode, where records are separated by one or more consecutive blank lines.n=split($0,a,"\n");: split the current record (paragraph) on\ninto the arraya. The number returned (n) is the number of elements in this array, so the number of\ncharacters in this record, and therefore the number of attributes plus one.print $2,n-1: print the second field (since we are using space and=as the field separator, on your file this will be the string after the first space and before he first,), and the value ofnminus one, so the number of lines minus one.