Re: grep & egrep script problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02Nov2006 10:11, Paul Ward <pnward@xxxxxxxxxxxxxx> 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@xxxxxxxxxx> 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.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux