I'm trying to create a script that takes two parameters: a word and a character, then returns how many times the character appears in the word.
Here is my code:
#!/bin/bash
((counter=0))
for i in $1
do
if i == $2
then
((counter=counter+1))
fi
echo $counter
done
My script returns 1 every time. I'm only versed in python, so my bash syntax is poor. Thanks in advance.