LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-07-2007, 12:55 PM   #1
romainp
LQ Newbie
 
Registered: Aug 2007
Posts: 18

Rep: Reputation: 0
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

Last edited by romainp; 09-07-2007 at 12:56 PM. Reason: error
 
Old 09-07-2007, 03:30 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
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

Last edited by Tinkster; 09-07-2007 at 03:33 PM. Reason: re-ran with negation of result
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
giving search-string(s) from a file to linux "find" command Fond_of_Opensource Linux - Newbie 3 02-02-2009 06:14 PM
JS: can html entities be found in a string? eantoranz Programming 4 08-22-2006 04:05 PM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
use grep and execute a command if string is found plisken Linux - General 6 07-28-2005 11:06 AM
[php] comparing found username with string Erhnam Programming 4 03-15-2005 09:34 PM


All times are GMT -5. The time now is 05:56 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration