It is simple! You can use & for this even for the bash function:
#!/usr/bin/bash x() { echo =$1=Solaris; sleep 1; echo =$1=East; sleep 1; echo =$1=Panta Rhei;} x one& x two& echo Syrius; sleep 1 echo After Crying
Output:
=one=Solaris Syrius =two=Solaris =one=East =two=East After Crying Press ENTER or type command to continue =one=Panta Rhei =two=Panta Rhei
So x runs in the background and prints to stdout . Press ENTER or type command to continue was introduced by vim (as I started the script from vim ) and shows that the background process x exits after the main script has finished. If you want to wait until all background processes are complete, you can use $! to get the PID of the background processes and the built-in wait <PID> as the last function.
source share