Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Redirecting output
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 989

PostPosted: Mon Dec 17, 2012 10:33 pm    Post subject: Redirecting output Reply with quote

I've been referring to this for info on redirecting output:

http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

Should I be using the "Bourne Shell Family" stuff? If so, does "2>&1 > /dev/null" redirect standard and error output to nowhere? If not, how is that done with the Bourne shell?
Back to top
View user's profile Send private message
lxg
Veteran
Veteran


Joined: 12 Nov 2005
Posts: 1019
Location: Aachen, Germany

PostPosted: Mon Dec 17, 2012 10:40 pm    Post subject: Re: Redirecting output Reply with quote

grant123 wrote:
Should I be using the "Bourne Shell Family" stuff?


If you didn't explicitely change your shell, you, as a Gentoo user, are most certainly using bash, the “Bourne Again Shell”, a successor the original Bourne Shell.

grant123 wrote:
If so, does "2>&1 > /dev/null" redirect standard and error output to nowhere?


Yes, it should, though the common expression is

Code:
… >/dev/null 2>&1


(First, redirect STDOUT to /dev/null, then redirect STDERR to STDOUT.)

You might want to read the following for details: http://www.tldp.org/LDP/abs/html/io-redirection.html
_________________
lxg.de – codebits and tech talk
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 202
Location: Switzerland

PostPosted: Tue Dec 18, 2012 10:20 am    Post subject: Reply with quote

you can also use the following command to redirect stderr and stdout to /dev/null

Code:
 $command &>/dev/null
Back to top
View user's profile Send private message
fturco
l33t
l33t


Joined: 08 Dec 2010
Posts: 629
Location: Italy

PostPosted: Tue Dec 18, 2012 11:43 am    Post subject: Re: Redirecting output Reply with quote

grant123 wrote:
If so, does "2>&1 > /dev/null" redirect standard and error output to nowhere?


The order is important. 2>&1 > /dev/null is not the same as > /dev/null 2>&1.


  • 2>&1 > /dev/null: standard error is redirected to the terminal (as standard output is); then standard output is redirected to /dev/null (but standard error still points to the terminal)
  • > /dev/null 2>&1: standard output is redirected to /dev/null; then standard error is redirected to /dev/null too (because standard output points to that now)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum