LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   egrep to find a command not found string (http://www.linuxquestions.org/questions/linux-general-1/egrep-to-find-a-command-not-found-string-582977/)

romainp 09-07-2007 12:55 PM

egrep to find a command not found string
 
Hi,
I have to test is the result of a command result with a 'command not found' string.
Let say that the command is :

Code:

vgdisplay -v
If the system does not have the vgdisplay utilisty, it will display for ex :

Code:

./sysinfocollector: vgdisplay: command not found
What I want is to check if the result contain the string 'command not found' in the string below.
I have tested :
Code:

if ! [ vgdisplay -v 2>&1 | egrep -q 'command' ]; then
But that does not seems to work ...
Any idea?

Thanks

Tinkster 09-07-2007 03:30 PM

You're thinking too complicated ...

Code:

[tink:~]$ if vgdisplay -v 2>&1| egrep -qv "not found";then echo YUP; fi
[tink:~]$ if ls 2>&1| egrep -qv "not found";then echo YUP; fi
YUP
[tink:~]$



Cheers,
Tink


All times are GMT -5. The time now is 11:39 PM.