Shell Script: Running parallel process in subshells


cat   list1  list2  list3  | sort |    uniq  >  list123  &

cat   list4  list5  list6  | sort |    uniq  >  list456  &

wait                   #Doen’t execute the next command until subshells finish

diff        list123     list456

Note1: If no argument is specified, wait waits until all processes (started with &) of the current shell have completed, and reports on abnormal terminations.

Note2:  Because the wait() system call must be executed in the parent process, the shell itself executes wait without creating a new process.

Happy Reading & Sharing!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: