Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make bash job control quiet?

Bash is quite verbose when running jobs in the background:

$ echo toto& toto [1] 15922 [1]+  Done                    echo toto 

Since I'm trying to run jobs in parallel and use the output, I'd like to find a way to silence bash. Is there a way to remove this superfluous output?

like image 875
static_rtti Avatar asked Jun 19 '12 09:06

static_rtti


People also ask

How do I make my Bash script silent?

To silence the output of a command, we redirect either stdout or stderr — or both — to /dev/null. To select which stream to redirect, we need to provide the FD number to the redirection operator.

What is Bash job control?

Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point. A user typically employs this facility via an interactive interface supplied jointly by the system's terminal driver and Bash. The shell associates a job with each pipeline.

How do I force quit Bash?

There are many methods to quit the bash script, i.e., quit while writing a bash script, while execution, or at run time. One of the many known methods to exit a bash script while writing is the simple shortcut key, i.e., “Ctrl+X”. While at run time, you can exit the code using “Ctrl+Z”.


1 Answers

You can use parentheses to run a background command in a subshell, and that will silence the job control messages. For example:

(sleep 10 & ) 
like image 176
Todd A. Jacobs Avatar answered Sep 20 '22 19:09

Todd A. Jacobs