title: Bash progress bar when running commands from within a script
body: <p>I'm writing a <code>bash</code> script which performs an installation of stuff.</p>
  
  <p>I don't want the user to see the commands and their output, so I'll redirect them using <code>2&gt;&amp;1</code>. </p>
  
  <p>I do wish to print a progress bar for each section which finished installing, and a success/failed message according if there were errors, for example:</p>
  
  <pre><code>Installing OpenCv ..................... [Success]
  Installing Qt     ..................... [Failed]
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>#!/bin/bash
  
  installOf="Installing OpenCv  "
  
  function printProgressBar() 
  {
      local progressBar="."
      printf "%s" "${progressBar}"
  }
  
  function InstEssent
  {
      sudo apt-get -y install build-essential
      sleep 5
      echo "Done"
  }
  
  printf "%s" "${installOf}"
  
  InstEssent  &amp;
  
  while [ "${InstEssent}" != "Done" ]
  do
      printProgressBar 
      sleep 1
  done
  
  installStatus="Success"
  printf " [%s]\n" "${installStatus}"
  </code></pre>