title: bash async function
body: <p>I have a for loop, within loop, there is while loop, the problem is when the while loop executed, the next for loop never executed.</p>
  
  <pre><code>sync[0]='/home/lzyy/tmp,12.34.56.78,test'
  sync[1]='/home/lzyy/tmp,23.45.67.89,test'
  
  for item in ${sync[@]}; do
  
  echo $item #only output sync[0]
  dir=`echo $item | awk -F"," '{print $1}'`
  host=`echo $item | awk -F"," '{print $2}'`
  module=`echo $item | awk -F"," '{print $3}'`
  
  inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format  '%T %w%f %e' \
   --event CLOSE_WRITE,create,move,delete  $dir | while read  date time file event
      do
          echo 
          # do something, 
      done
  done
  </code></pre>
  
  <p>what I can find out to solve this problem is async function, or save the while loop in a separate file, and executed background.</p>