Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


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

Rep: Reputation: 0
egrep to find a command not found string

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

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

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


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

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
You're thinking too complicated ...

[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


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


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 > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:54 PM.

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