LinuxQuestions.org
Review your favorite Linux distribution.
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, 06: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, 06:53 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

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

Check the man page of grep and look for the -q (quiet) option.
 
Old 02-11-2010, 07: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, 07: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 12:09 PM
using grep command hiteshthappa Linux - Newbie 4 07-11-2008 08:34 AM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 04:16 AM
using grep command mruknown1 Linux - Newbie 11 09-11-2007 11:06 AM
grep command karimasif Linux - Newbie 2 09-05-2007 11:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:53 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
Open Source Consulting | Domain Registration