Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash count occurrences of string in array

let count=0
for x in ${my_array[*]}; do
  if [ $x == 'abc' ]
  then
    count=$((count+1))
  fi
done
 
PREVIOUS NEXT
Tagged: #bash #count #occurrences #string #array
ADD COMMENT
Topic
Name
7+8 =