LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-25-2007, 06:45 AM   #1
swiftguy121
LQ Newbie
 
Registered: Mar 2007
Posts: 10

Rep: Reputation: 0
Suppressing error messages in BASH Shell


Hello Experts,

I want error messages of Linux commands to be redirected to '/dev/null' , I know we can redirect the error messages by running an individual command ..but i want this to be a standard feature in my BASH environment(All Linux command error messages to be sent to /dev/null/). I did lot of googling and could find that the command to get this done is

"2>/dev/null"
or
"exec 2>/dev/null"

I tried both in .bash_profile file, but still i see Linux command error messages displayed on the stdout.

Plz help me with the above problem.

Thx in advance.
 
Old 05-25-2007, 06:51 AM   #2
Okie
Senior Member
 
Registered: Mar 2002
Location: Oklahoma
Posts: 1,154

Rep: Reputation: 187Reputation: 187
umm, i think those error messages are there for a reason, one day you may need them to resolve a problem...
 
Old 05-25-2007, 07:52 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
You may decide that both stderr and stdout are directed to /dev/null this way:
exec 1>/dev/null 2>/dev/null
but then you won't even have an "echo" of what you type...

Yves.
 
Old 05-25-2007, 08:35 PM   #4
swiftguy121
LQ Newbie
 
Registered: Mar 2007
Posts: 10

Original Poster
Rep: Reputation: 0
"TheYinYeti",
Thx for responding what if i want to direct only stderr messages to /dev/null ?
 
Old 05-25-2007, 08:59 PM   #5
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Your best bet is just the 2>/dev/null, at the end of the commands you type.

Why do you not want to see error messages? They can be very useful in trying to solve problems.

You can, of course, create aliases for commands that you regularly use that you don't want to see the error messages:
Code:
alias ls = "ls 2>/dev/null"
in .bashrc.

I hope this helps
--Ian
 
  


Reply



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
Suppressing linking messages on AIX montylee AIX 2 07-06-2005 06:17 AM
Redirecting error messages to stderr and file in Bash lowpro2k3 Programming 1 04-14-2005 06:47 PM
shell error messages not displayed as a message box!!! user222 Linux - General 10 10-25-2004 01:11 AM
bash scripting - suppress error messages? brian0918 Programming 2 06-19-2003 11:16 AM
Error messages when launching apps from shell prompt correro Linux - General 2 03-25-2003 07:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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