Finding a lost PYTHONPATH with find

Discussion in 'Python' started by John J. Lee, May 28, 2006.

  1. John J. Lee

    John J. Lee Guest

    OK, this is really a reminder to myself next time I forget where I set
    my PYTHONPATH and forget exactly how to invoke the GNU "find" command
    ;-)

    Hope somebody else finds it useful too

    find / -maxdepth 3 -size -100k -type f -exec grep -sli pythonpath '{}' \;


    The minus in '-100k' (meaning "less than 100k") seems to be
    undocumented, at least on my system. I suppose the -maxdepth is
    redundant since I think find searches breadth-first by default.

    The file I was looking for turned out to be in /etc/profile.d/, whose
    existence I completely forgot about...


    John
    John J. Lee, May 28, 2006
    #1
    1. Advertising

  2. John J. Lee wrote:

    > find / -maxdepth 3 -size -100k -type f -exec grep -sli pythonpath '{}' \;
    >
    >
    > The minus in '-100k' (meaning "less than 100k") seems to be
    > undocumented, at least on my system.


    It should be standard in linux man pages, can't speak for other unices:

    TESTS
    Numeric arguments can be specified as

    +n for greater than n,

    -n for less than n,

    n for exactly n.

    Maybe you were fooled because it's not directly under the description of
    -size.


    > I suppose the -maxdepth is
    > redundant since I think find searches breadth-first by default.


    ??? maxdepth determines how deep the search will look, not the order the
    search occurs. Your search only find things within 3 levels of the root,
    unless your directory tree goes no deeper than that (very unlikely) the
    maxdepth can't be redundant.

    --
    Edward Elliott
    UC Berkeley School of Law (Boalt Hall)
    complangpython at eddeye dot net
    Edward Elliott, May 29, 2006
    #2
    1. Advertising

  3. John J. Lee

    John J. Lee Guest

    Edward Elliott <nobody@127.0.0.1> writes:

    > John J. Lee wrote:
    >
    > > find / -maxdepth 3 -size -100k -type f -exec grep -sli pythonpath '{}' \;
    > >
    > >
    > > The minus in '-100k' (meaning "less than 100k") seems to be
    > > undocumented, at least on my system.

    >
    > It should be standard in linux man pages, can't speak for other unices:
    >
    > TESTS
    > Numeric arguments can be specified as
    >
    > +n for greater than n,
    >
    > -n for less than n,
    >
    > n for exactly n.
    >
    > Maybe you were fooled because it's not directly under the description of
    > -size.


    Yes, that's right -- thanks.


    > > I suppose the -maxdepth is
    > > redundant since I think find searches breadth-first by default.

    >
    > ??? maxdepth determines how deep the search will look, not the order the
    > search occurs. Your search only find things within 3 levels of the root,
    > unless your directory tree goes no deeper than that (very unlikely) the
    > maxdepth can't be redundant.


    It can if you hit Control-C as soon as it finds the damn thing :) --
    which is exactly what I would have done, of course.


    John
    John J. Lee, Jun 1, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harald Kirsch

    jython and PYTHONPATH

    Harald Kirsch, Jun 28, 2003, in forum: Python
    Replies:
    1
    Views:
    1,206
    Ype Kingma
    Jun 30, 2003
  2. vincent delft

    CGIHTTPserver looze PYTHONPATH

    vincent delft, Jul 13, 2003, in forum: Python
    Replies:
    1
    Views:
    437
    vincent_delft
    Jul 13, 2003
  3. Wybo Dekker
    Replies:
    1
    Views:
    336
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    385
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    789
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page