Search code examples
bashshellparallel-processinggnu-parallel

parallel call multiple bash functions


I have read the example at http://www.gnu.org/software/parallel/man.html#example__calling_bash_functions however, is it possible to use gnu parallel to call 2 functions which do not have any variables you pass to them ?

example

a() {
  echo "download a"
  wget fileA
}

b() {
  echo "download b"
  wget fileB
}

and use parallel to call both functions a & b ?


Solution

  • Run them in background. And then wait for them to complete.

    a() {
      echo "download a"
      wget fileA
    }
    
    b() {
      echo "download b"
      wget fileB
    }
    
    a &
    b &
    wait # waits for all background processes to complete