in reply to Re: Search through multiple files and output results to new file
in thread Search through multiple files and output results to new file

Why can't you run multiple instances of it?

Two reasons:

  1. Each instance would be trying to process the same files.

    Which would mean lots of "file in use" errors and/or duplicated results.

  2. The multiple instances would be trying to redirect their output to the same file.

    Even if you use append (>>), Windows won't let you do that. Not sure if *nix will?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy
  • Comment on Re^2: Search through multiple files and output results to new file
  • Download Code

Replies are listed 'Best First'.
Re^3: Search through multiple files and output results to new file
by JavaFan (Canon) on Aug 24, 2010 at 20:00 UTC
    Each instance would be trying to process the same files.
    Oh. I never got the impression that the OP wanted this. I fail to see why that's a benefit.
    Which would mean lots of "file in use" errors and/or duplicated results.
    Windows doesn't allow two processes to open the same file? That sounds like an easy DoS.
    The multiple instances would be trying to redirect their output to the same file. Even if you use append (>>), Windows won't let you do that. Not sure if *nix will?
    Unix allows multiple processes to write to the same file. And if the file is opened in append mode, all write()s will go to the end of the file.
      Oh. I never got the impression that the OP wanted this. I fail to see why that's a benefit.

      If you start two concurrent instances of grep with a wildcard filespec, (win or *nix), then both instances will expand that wildcard to the same list.

      So then the problem becomes, how do you distribute the file list across multiple grep instances?

      Windows doesn't allow two processes to open the same file?

      It does, but not by default. And the permissions required are not available from perl.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        So then the problem becomes, how do you distribute the file list across multiple grep instances?
        There are several ways - the more you know about the file(s), the more options you have. However, that still uses grep.

        Perhaps the OP can first elaborate on what's he's trying to achieve before offering solutions based on guesses.