I've got a program (prog
) that takes a lot of time to produce its output.
I need to check if the output contains string1 and not string2.
Right now I do the following. It invokes prog
2 times.
if prog | grep -q 'some string' &&
! prog | grep -q 'another string'; then
echo 'OK'
else
echo 'Not OK'
fi
Is there are way to do this with only 1 invocation of prog
?
Any solution involving awk or sed will do as well.
UPDATE
What I was hoping for was a one liner—that my mind cannot see—to do the trick, having GNU coreutils at my disposal.