Is there an inbuilt command to do this or has anyone had any luck with a script that does it?
I am looking to count the number of times a certain string (not word) a
text="(\*)" grep -o $text file | wc -l
You can make it into a script which accepts arguments like this:
script count:
#!/bin/bash text="$1" file="$2" grep -o "$text" "$file" | wc -l
Usage:
./count "(\*)" file_path