I have this variable:
>echo $br_name
srxa wan-a1 br-wan3-xa1 0A:AA:DD:C1:F1:A3 ge-0.0.3 srxa wan-a2 br-wan3-xa2 0A:AA:DD:C1:F2:A3 ge-0.0.3
I am trying to create a conditional where it detects whether ge-0.0.3 is repeated more than 1 time in my variable $br_name
For example:
if [[ $br_name has ge-0.0.3 repeated more than one time ]]
then
echo "ge-0.0.3 is shown more than once"
else
:
fi
simple word
If your word would be "easy", you can detect the occurrences count with:
In which the word is replace for the same but with
\n
and thenwc
count the linesor you can try one of these:
complex
Since your word is "complex" or you will want a pattern, you will need regex:
script.sh
execution
grep
With grep you can get the ocurrence count