LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-12-2003, 01:29 PM   #1
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Rep: Reputation: 30
Trapping an exit status


How could I trap the exit status of grep. The possible exit statuses are 0,1,2. When I'm writing a shell script and executing grep. how can I store these values into a variable?
 
Old 09-12-2003, 02:41 PM   #2
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
Well nevermind, I figured it out. There is a builtin variable that catches returned exit statues. Its $? just for future reference.
 
Old 09-12-2003, 07:08 PM   #3
richhill
LQ Newbie
 
Registered: Sep 2003
Location: Mesa, AZ, USA
Distribution: SuSe 8.1, Mandrake 6.2
Posts: 12

Rep: Reputation: 0
So if you were just interested in the return code of grep, did you just redirect the STDOUT to /dev/null ??
 
Old 09-12-2003, 10:02 PM   #4
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
Yup actually I did redirect it out /dev/null
 
  


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
exit status naflan Programming 2 10-22-2004 01:22 PM
exit status 17 kppp joshy Mandriva 3 10-08-2004 08:07 AM
error exit status 30 debian_dummy Debian 2 09-21-2004 11:26 PM
pppd exit status 1 wolfe2554 Linux - Networking 2 04-14-2004 01:15 AM
gcc exit status 1 Daddio Linux - Software 4 10-25-2003 06:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:27 PM.

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