LinuxQuestions.org
Visit Jeremy's Blog.
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 05-09-2007, 06:00 PM   #1
budword
Member
 
Registered: Apr 2003
Location: Wisconsin
Distribution: Switched to regualr Ubuntu, because I don't like KDE4, at all. Looks like vista on crack.....
Posts: 675

Rep: Reputation: 31
bash shell script error redirect problem.....


Hi, I have a simple bash script, and I want to redirect all errors to /dev/null (I think), anyway, I just want them to disappear. I'm sure this is a simple thing, (for most of you), but 5 minutes of googling and a simple search here yielded no help.

I think there is a quick and easy solution, but I can't seem to find it quickly or easily, yet.

Thanks much...

David
 
Old 05-09-2007, 06:10 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Something like
Code:
command_name >/dev/null 2>&1
redirects stdout to /dev/null, and redirects stderr to stdout (thereby accomplishing the end-goal).
 
Old 05-09-2007, 06:21 PM   #3
budword
Member
 
Registered: Apr 2003
Location: Wisconsin
Distribution: Switched to regualr Ubuntu, because I don't like KDE4, at all. Looks like vista on crack.....
Posts: 675

Original Poster
Rep: Reputation: 31
How do I make that apply to the entire script ? Does bash have an option I can set at the beginning of the script ?
 
Old 05-09-2007, 06:30 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by budword
How do I make that apply to the entire script ?
Use the bash builtin “exec”
 
Old 05-09-2007, 07:32 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
<command_name> could be the name of your script.

./scriptname 2>/dev/null

Last edited by jschiwal; 05-10-2007 at 01:59 AM.
 
  


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
shell script: redirect to variable va1damar Programming 1 02-05-2007 04:11 PM
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 07:30 PM
bash shell script problem sorno Programming 1 07-30-2005 05:02 AM
bash shell script problem shanenin Linux - Software 5 02-09-2004 09:22 PM
bash shell script problem evilchild Programming 7 02-08-2004 10:09 PM

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

All times are GMT -5. The time now is 06:19 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