Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I often launch applications from the cli via e.g. command & to immediately get back to the prompt back. The downside of this is, that I still get STDOUT and STDERR.

So I use command &> /dev/null to discard those outputs.

This can get quite a chore, when having to write this often during a day.

So my question is, is there a better (read shorter) way to discard of STDOUT and STDERR when not needed?

What could be done? Maybe write a wrapper script to launch applications? What would be an elegant way to do this?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can define a function (e.g., in your .alias, .bashrc file)

launch () 
{ 
    "$@" >&/dev/null &
}

This can then be used as

launch command

For example

launch xemacs ./myfile.txt
share|improve this answer
    
Use "$@" >&/dev/null & to avoid problems with spaces, wildcards, etc in the command's arguments. –  Gordon Davisson Dec 14 '12 at 19:41
    
@GordonDavisson Thanks, I edited the answer. –  Matteo Dec 14 '12 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.