LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-11-2010, 07:45 AM   #1
podariu
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Rep: Reputation: 0
command grep


hi
im a beginner with linux and i want to know if there is a a way like the following command returns 0 for true , 1 for false and 2 for an error and not returning what is usually returnd the grep command

grep bla out.txt
 
Old 02-11-2010, 07:53 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Hi and welcome to LinuxQuestions!

Check the man page of grep and look for the -q (quiet) option.
 
Old 02-11-2010, 08:00 AM   #3
backtolinux
LQ Newbie
 
Registered: Nov 2009
Posts: 20
Blog Entries: 1

Rep: Reputation: 2
in unix, 0 said succesfull execution, others than 0 said failed execution.

After issuing your command, get the values by "echo $?", the value returned by the last command.
 
Old 02-11-2010, 08:15 AM   #4
podariu
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Smile

it works
thanks guys
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass the result of a command to another command (like grep) desb01 Programming 4 06-25-2009 01:09 PM
using grep command hiteshthappa Linux - Newbie 4 07-11-2008 09:34 AM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 05:16 AM
using grep command mruknown1 Linux - Newbie 11 09-11-2007 12:06 PM
grep command karimasif Linux - Newbie 2 09-05-2007 12:54 PM


All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
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