Word count with grep
Hi.
I've got a text file with some data in it and I want to know how many times the letter 'x' occurs in it, my problem is that x occurs many times on one line so I can't use grep -c. What's the best way to do this? I'm sure there must be a simple solution, but I can't seem to find it! Thanks for your help. |
Code:
cat file | tr -d -c "x" | wc -c |
Thanks! I'm quite pleased to see it wasn't a really obvious solution that I'd missed.
|
Nope, not terribly obvious. But I do like my shell tricks.
|
All times are GMT -5. The time now is 11:31 AM. |