Results 1 to 4 of 4

Thread: reset grep and find indexes

  1. #1
    grglsn NNTP User

    Default reset grep and find indexes

    Howdy,

    I was using grep and find to search through a particular directory and
    find all the files with a particular string in it, like "foo".

    here is the code:
    Code:
    grep "foo" *
    So then I went into each of those files and changed every instance of
    that string in each file to "fobo".

    Then when I run the grep command again, no files should come up again in
    the list, right? Because they have all been changed. However, the output
    of the grep command is the same as before, as if they have not been
    changed, which I assume is because there is some kind of index file that
    grep reads to speed up its search process.

    The same thing happens with find, if I run it as follows:
    Code:
    find . -name "*" -print | xargs grep "foo"
    So how do I reset the index file to re-read the directory in question,
    so that an accurate representation of the files will show up with grep
    and find?


    --
    G.O.
    Box #1: 12.3 | KDE 4.10 | AMD Phenom IIX4 | 64 | 16GB
    Box #2: 12.2 | KDE 4.9.2 | AMD Athlon X3 | 64 | 4GB
    Laptop: 12.3 | KDE 4.10 | Core i7-2620M | 64 | 8GB

  2. #2
    grglsn NNTP User

    Default Re: reset grep and find indexes

    On 08/24/2013 04:06 PM, arvidjaar wrote:
    >
    > grglsn;2581319 Wrote:
    >> I assume is because there is some kind of index file that
    >> grep reads to speed up its search process.

    >
    > There is no such thing. Grep does not use any indexes.
    >
    >


    ok, I believe you. But then what causes grep to give me the same output
    as before even after I have removed all of the strings in all of the
    files in a particular directory?

    --
    G.O.
    Box #1: 12.3 | KDE 4.10 | AMD Phenom IIX4 | 64 | 16GB
    Box #2: 12.2 | KDE 4.9.2 | AMD Athlon X3 | 64 | 4GB
    Laptop: 12.3 | KDE 4.10 | Core i7-2620M | 64 | 8GB

  3. #3
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: reset grep and find indexes

    On 2013-08-24 10:21, grglsn wrote:
    > On 08/24/2013 04:06 PM, arvidjaar wrote:



    > ok, I believe you. But then what causes grep to give me the same output
    > as before even after I have removed all of the strings in all of the
    > files in a particular directory?


    Because "foo" is contained in "fobo". I mean, the search string is still
    to be found in those files. Or because it is finding the backup~ files.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

  4. #4
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,066

    Default Re: reset grep and find indexes

    On Sat, 24 Aug 2013 08:21:16 +0000, grglsn wrote:

    > On 08/24/2013 04:06 PM, arvidjaar wrote:
    >>
    >> grglsn;2581319 Wrote:
    >>> I assume is because there is some kind of index file that grep reads
    >>> to speed up its search process.

    >>
    >> There is no such thing. Grep does not use any indexes.
    >>
    >>
    >>

    > ok, I believe you. But then what causes grep to give me the same output
    > as before even after I have removed all of the strings in all of the
    > files in a particular directory?


    Can you provide a simple example - say a single file in a directory that
    has the value being found (and the contents of the file), and then the
    output after you've made the change - and information about how you made
    the change?

    As others have said, grep doesn't use indexes, so what you're seeing
    shouldn't be possible. That means we need more details to figure out
    what's going on.

    Jim



    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •