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).


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.

  • thank you! that explain why I was only getting fifo and input results on google :D – Plante Jul 2 '11 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. – user unknown Jul 2 '11 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 Jul 2 '11 at 20:50
  • That's exactly what I needed, thanks again. works great so far! – Plante Jul 3 '11 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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