[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grep
From: |
Jérôme Arfouche |
Subject: |
Re: grep |
Date: |
Tue, 7 Oct 2008 08:31:36 -0400 |
right, well thanks, i'll try the find command you gave me....
but one last time, i'll send you in details what i'm doing....
grep -c "#\!" * | grep :0
a.pm:0
b.pm:0
c.pm:0
d.pm:0
e.pm:0
f.pm:0
g.pm:0
h.pm:0
src:0
grep -c -d skip "#\!" * | grep :0
a.pm:0
b.pm:0
c.pm:0
d.pm:0
e.pm:0
f.pm:0
g.pm:0
h.pm:0
src:0
grep "#\!" *
bla.pm:#!/usr/bin/perl
test.pl:#!/usr/bin/perl
x.pl:#!/usr/bin/perl
y.pl:#!/usr/bin/perl
z.cgi:#!/usr/bin/perl -w
grep -d skip "#\!" *
bla.pm:#!/usr/bin/perl
test.pl:#!/usr/bin/perl
x.pl:#!/usr/bin/perl
y.pl:#!/usr/bin/perl
z.cgi:#!/usr/bin/perl -w
src is the dir that keeps popping up everytime, -d skip just doesn't seem to
have any effect...i tried -d recurse to see if the -d option was actually
working, and it did, but not for -d skip...
anyway, thanks...
2008/10/6 Bob Proulx <address@hidden>
> Jérôme Arfouche wrote:
> > my grep version is "grep (GNU grep) 2.5.1"
>
> That should be okay. I tested using 2.5.1 and I could not recreate
> your failure. I used Debian Stable for my test and it was okay for me.
>
> > and i have this problem when i try to do this:
> > [...fixed...] grep -c -d skip "\#\!" * | grep :0 | wc -l
> > basically it's supposed to look for FILES (skip dir) that don't have the
> > shebang line and count them, that's it
> > for some reason it keeps counting my directories with it
>
> I do not see that myself. See the example that I posted:
>
> > > mkdir t && cd t
> > > mkdir a b c
> > > echo foo1 > a/one
> > > echo foo2 > b/two
> > > echo foo3 > c/three
> > > echo foo4 > four
> > >
> > > grep -d skip -c foo ./*
> > > ./four:1
> > >
> > > grep -c -d skip foo ./*
> > > ./four:1
>
> The skip seems to be working okay to me. By contrast if I change this
> to be 'read' then I see what you are describing. I am using grep
> version 2.5.1 for this testing.
>
> grep -d read -c foo ./*
> ./a:0
> ./b:0
> ./c:0
> ./four:1
>
> Unfortunately since it seems to be behaving here unless someone else
> can replicate the problem it means that you are the only one able to
> debug your problem further.
>
> Alternatively I believe that 'find' is the better tool for the job.
> Try this instead:
>
> find . -maxdepth 1 -type f -exec grep -c "#\!" {} + | grep -c :0
>
> The '!' only needs to be escaped for csh and bash history expansion.
> The grep argument will be seen as "#!" after shell processing. Other
> shells might need or not need this escaping or using '#!' is common on
> unix shells. The '#' is okay without escaping. Sometimes unused
> escapes are then used later so it is better to avoid them.
>
> Bob
>
- grep, Jérôme Arfouche, 2008/10/04
- Re: grep, Bob Proulx, 2008/10/04
- Re: grep, Jérôme Arfouche, 2008/10/06
- Re: grep, Bob Proulx, 2008/10/06
- Re: grep,
Jérôme Arfouche <=
- Re: grep, Jérôme Arfouche, 2008/10/06