Let's say I have a bash script with the following:

rm *.temp

When I execute it using sh ./test.sh, gedit pops-up but the rm part does not run until after I close gedit.

I want the script to continue running even if gedit isn't closed; like the gedit isn't blocking the bash execution.

The example I gave is just an example (putting the rm first won't work in a real situation).


2 Answers 2


The term you are looking for is called "backgrounding" a job. When you run a command either in your shell or in a script you can add a flag at the end to send it to the background and continue running new commands or the rest of the script. In most shells including sh, this is the & character.

gedit &
rm ./*.temp

That way, the shell doesn't wait for the termination of gedit and both rm and gedit will run concurrently.

The term "blocking" usually has to do with input/output streams, often to files or a device. It's also used in compiled languages in something similar to the sense you used, but in bash and similar shell scripting, the terminology (and function!) is rather different.

  • 1
    thank you! that explain why I was only getting fifo and input results on google :D
    – Plante
    Commented Jul 2, 2011 at 20:31
  • My impression is, that Plante wants to influence a script from outside, to perform each operation in background, not to rewrite the script. Commented Jul 2, 2011 at 20:46
  • @user: It took me a couple reads to even guess what he wanted. Maybe you could comment on the question for clarification.
    – Caleb
    Commented Jul 2, 2011 at 20:50
  • 1
    That's exactly what I needed, thanks again. works great so far!
    – Plante
    Commented Jul 3, 2011 at 0:33

This will not produce any output whatsoever. It will also detach from the Terminal and won't block anything:

nohup gedit >/dev/null 2>&1 &

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .