in reply to greping from directories

...my suggestion stems from the time-honored principle, "divide and conquer."

From a prompt, and while currently in the main23 directory, run the grep by hand. I'm betting that this is a problem that will reproduce when you do the operation by hand. If it does recur, then you can consider things like directory permissions and so forth.

If the grep command works from your shell prompt, but does not when you run your script, then you want to consider the effects of your quotation of the command, and you may also want to do some exploration to determine if the instance of grep that you run from your script is the same that runs when you use your shell.

I'll experiment here and see if I can see the same effect you are seeing.

---v

Replies are listed 'Best First'.
Re: Re: greping from directories
by agentv (Friar) on Jul 23, 2002 at 16:12 UTC
    ...FYI, I tried this approach on my own system and I reproduced the problem.

    But what I found is that I had supplied bad path names. When I used correct path names in my experiment, the code you supplied worked fine.

    The differences in my setup were that I created directories as you showed, but mine were beneath my home directory rather than immediately below the root directory. Otherwise, everything else was probably the same.

    Here's what I did:

    $ mkdir main22 main23 $ mkdir main22/loges main23/loge $ echo "john\nfile2" >main22/loges/de.pl $ echo "john1\nfile3" >main23/loge/do.pl $ grep file2 /home/flame/main23/loge/do.pl /home/flame/main22/loges/de +.pl $ perl -e 'system qq{grep file2 /home/flame16/main23/loge/do.pl /home/ +flame16/main22/loges/de.pl}'

    ---v