Wednesday 15 May 2013

shell - Calling "grep" and "head" from PHP -


I am trying to filter the contents of a set of files in the directory and before using this kind of command only Output N line:

  gzip -dc $ (% path-find folder% s) | Grep 27990 | Head-n 50   

In the terminal, this command takes you to complete a few seconds to run. But when I run it from PHP it takes about an hour, because the total size of the files seems to be larger, like php is waiting until the gzip command is over. But if I run simple:

  gzip -dc $ (find / opt / data / bi / ets / 20130616). Head-N50   

This results in immediate results. I tried backquotes, exec, system.

Here is the php code:

  $ cmd = 'gzip -dc $ (' find '$ path.' | Grep -E "'.' $ Regexp. ' "). Grep -E "'. $ This- & gt; _buildRegExp ().' $ '[' Border ']; $ Res = `$ cmd`;   

How to fix it?

Instead of using passthru to get all the output, not only the last string

  ($ CMD , $ Output); $ output echo;    

No comments:

Post a Comment