Count the number of elements in an Array

Sort by

recency

|

77 Discussions

|

  • + 1 comment
    awk 'END {print NR}'
    
  • + 0 comments
    #!/bin/bash
    
    readarray bal
    
    printf "%s\n" ${bal[@]} | wc -l
    

    my elegant solution

  • + 0 comments
    readarray a;
    echo "${#a[@]}"
    
  • + 1 comment
    wc -l
    
  • + 0 comments
    tab=()
    while read country; do 
        tab+=("$country")
    done
    
    # print length of table
    echo "${#tab[@]}"