Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!
There's something bizarre happening on one of the Macs at work. The screen wiggles all around when you move the mouse. It's like pan and scan. Through an earthquake. Is it possessed? Can I make it stop?
Sounds like you've got the "Easy Access" turned on in OS9 [link] or it's equivelent in OSX [link] .
Is there a way to use grep (or something similar) that will give me just a single count of all matches for multiple files? I can do this:
grep -cirh "panda" *
and it just returns the count of the matches, except it returns one number for each file. I want the total for all files.
Bless!
You know, zoom on a huge monitor doesn't zoom so much as shimmy shimmy.
All better now.
perl -lne '$tot += grep /panda/i, split; END { print $tot }' *
Will count the number of occurrences of each word. Using grep will count the word only once, even if it occurs multiple times per line.
Thanks!
I'll have to stare at that later to figure out how it works (haven't done any perl coding in a few years).
Tom, is the search case-sensitive? Would you need to pass the -c parameter to grep for a non-case sensitive search?
Actually, this might hurt your head less, tommyrot:
cat * | grep -cirh "panda"
What version of grep are you using, Eddie? In GNU grep, those options don't do what you think they do.
Tommyrot, the "/i" at the end of the "/panda/i" pattern makes it case insensitive.
Tommyrot, the "/i" at the end of the "/panda/i" pattern makes it case insensitive.
Oh, OK, that makes sense.
grep 2.5.1-26
Ok, I just copied tommyrot's switches, but this would be more correct:
cat * | grep -ci "panda"