grep & egrep script problem

Cameron Simpson cs at zip.com.au
Fri Nov 3 00:47:33 UTC 2006


On 02Nov2006 10:11, Paul Ward <pnward at googlemail.com> wrote:
| Unfortunately this does not work as it greps for test2 on the output
| of the test1 grep which returns no output.

That's the idea.

| The command needs to grep for test1 and test2 not either or

So you want to test for test1 OR test2 on each line, not test1 AND
test2?

You could run ps into a file, then loop over each test:

  tmpfile=/tmp/pstest$$
  ps ... >"$tmpfile"
  ok=1
  for test in test1 test2 test3 ...
  do  egrep "$test" "$tmpfile" >/dev/null || { ok=; break; }
  done
  rm "$tmpfile"
  [ $ok ]

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The first ninety percent of the task takes ninety percent of the time, and
the last ten percent takes the other ninety percent.




More information about the fedora-list mailing list