I want to loop while grep does or does not find something I can write:
while grep 'matches' inLogFile.txt
do
echo good.
sleep 10
done
Or
while grep -v 'notHereYet' inLogFile.txt
do
sleep 2
done
echo -e '\a'Yo! It is here now.
I'm typing these at the interactive shell prompt.
So I wanted to repeatedly check df
for when a volume actually got mounted, kind of like:
while df | grep -v '/toBeMounted'
do
sleep 2
done
echo -e '\a'Hey, I think you wanted to know that /toBeMounted is available finally.
I'm having trouble figuring out how to group the pipe into the condition.
I know I could do something like:
while [ -z "$(df|grep '/toBeMounted')" ]
do
sleep 2
done
echo -e '\a'Okay that is finally present now.
Yet I feel as though there should be a way to do it using exit values instead of the string comparison.
-q
will allow grep to exit with a status instead, which is more suitable for statements-q
makes even more sense in this case.