That's insane troll logic!

Xander ,'Showtime'


Buffistechnology 2: You Made Her So She Growls?  

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!


tommyrot - Aug 04, 2005 9:00:21 am PDT #3875 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

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).


tommyrot - Aug 04, 2005 9:13:56 am PDT #3876 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

Tom, is the search case-sensitive? Would you need to pass the -c parameter to grep for a non-case sensitive search?


Eddie - Aug 04, 2005 9:14:23 am PDT #3877 of 10003
Your tag here.

Actually, this might hurt your head less, tommyrot:

cat * | grep -cirh "panda"


Tom Scola - Aug 04, 2005 9:18:10 am PDT #3878 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

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 - Aug 04, 2005 9:19:09 am PDT #3879 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

Tommyrot, the "/i" at the end of the "/panda/i" pattern makes it case insensitive.

Oh, OK, that makes sense.


Eddie - Aug 04, 2005 9:21:24 am PDT #3880 of 10003
Your tag here.

grep 2.5.1-26

Ok, I just copied tommyrot's switches, but this would be more correct:

cat * | grep -ci "panda"


Tom Scola - Aug 04, 2005 9:23:52 am PDT #3881 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

As I said before, that will only print out the number of lines that match, not the number of words.


Eddie - Aug 04, 2005 9:26:13 am PDT #3882 of 10003
Your tag here.

D'oh! Yeah, you're right.

Here:

cat * | grep -i "panda" | wc -w

or to go within directories:

grep -ir "panda" * | wc -w


Tom Scola - Aug 04, 2005 9:34:09 am PDT #3883 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

That will count the number of words in lines that have "panda" in them, including all the words that aren't "panda".


Eddie - Aug 04, 2005 9:36:00 am PDT #3884 of 10003
Your tag here.

Ok, you win... I need more sleep.