The problem is this:
For example, I have a file "a.xml". Inside this file, it's just one line like
<queue><item><cause><item>
I want to find how many times <item>happens, in which case it is 2.
However, if I run:
grep -c "<item>" a.xml
This will give me only 1, because grep stops as soon as it matches the first <item>.
So my problem is how to use a simple shell / bash command that returns the number of times <item>?
It looks simple, but I just can't find a good way. Any ideas?
source
share