title: cURL surpress progress stats after cURL download has finished
body: <p>I have this simple script:</p>
  
  <pre><code>printf "* Download Status: Pending..."
  
  # Get HTML content from homepage
  homepage=$(curl -s "https://example.com/")
  wait
  
  printf "\r* Download Status: Successful\n"
  </code></pre>
  
  <p>The <code>\r</code> simulates carriage return and prints <code>Download Status: Successful</code> after the download finishes, hereby removing <code>Download Status: Pending...</code>. This works flawlessly.</p>
  
  <p>If I omit the <code>-s</code> flag, <code>curl</code> will show the statistics until the download is complete.</p>
  
  <ul>
  <li>How can I show the statistics during the download and remove them when <code>curl</code> is finished?</li>
  </ul>
  
  <p>I tried using something like:</p>
  
  <pre><code>printf "&lt; Download Status: Pending...\n\n"
  
  # Get HTML content from homepage
  homepage=$(curl "https://example.com/")
  wait
  
  printf "\r\r\r\r\r\r&gt; Download Status: Successful\n"
  </code></pre>
  
  <p>The reason for me using that many <code>\r</code> is because I'm leaving some space at the beginning (<code>\n</code>) and the <code>curl</code> statistics themselves are 3 lines long. I thought this might remove them but it obviously doesn't, instead it outputs both of the <code>printf</code> with the <code>curl</code> stats in between them!</p>
  
  <ul>
  <li>Can anyone tell me why?</li>
  </ul>
  
  <hr>
  
  <p><strong>ALTERED ANSWER</strong></p>
  
  <p>According to @jmd_dk 's genius use of variables, this worked for my case:</p>
  
  <pre><code># Set ANSI codes as variables
  esc="\x1b"
  esc_up="${esc}[1A"
  esc_erase="${esc}[K"
  newline="\n"
  
  # Display status before download
  printf "* Download Status: Pending...${newline}${newline}"
  
  # Initiante cURL &amp; wait for HTML content from the homepage
  homepage=$(curl "https://example.com/")
  wait
  
  # Delete all lines up to download status
  printf "${esc_up}${esc_erase}"
  printf "${esc_up}${esc_erase}"
  printf "${esc_up}${esc_erase}"
  printf "${esc_up}${esc_erase}"
  printf "${esc_up}${esc_erase}"
  
  # Display status after completion
  echo "* Download Status: Successful"
  </code></pre>
  
  <p>I delete all lines else some parts of the <code>curl</code> stats will be showed, making the output messy.</p>