Answers for "bash count occurrences of string in variable"

1

count occurrences of word in unix bash

$ grep -o -i needs inspire.txt | wc -l
Posted by: Guest on May-13-2020
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 variable"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language