Answers for "bash count occurrences of string in array"

0

bash count occurrences of string in array

for word in ${myarr[*]}; do
  echo $word
done | grep -c "hello"
Posted by: Guest on February-26-2021
0

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
Posted by: Guest on February-26-2021

Code answers related to "bash count occurrences of string in array"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language