title: Multithreading in bash scripting
body: <p>I run a bash script, and looping as much line in text file. to cURL the site listed in the txt file.</p>
  
  <p>here is my script : </p>
  
  <pre><code>SECRET_KEY='zuhahaha'
  FILE_NAME=""
  
  case "$1" in
          "sma")     
              FILE_NAME="sma.txt"
          ;;
          "smk")      
              FILE_NAME="smk.txt"
          ;;
          "smp")      
              FILE_NAME="smp.txt"
          ;;
          "sd")      
              FILE_NAME="sd.txt"
          ;;
       *)
          echo "not in case !"
          ;;
  esac
  
  function save_log()
  {
      printf '%s\n' \
      "Header Code    : $1" \
      "Executed at    : $(date)" \
      "Response Body  : $2" \
      "====================================================================================================="$'\r\n\n'  &gt;&gt; output.log
  }
  
  while IFS= read -r line; 
      do 
          HTTP_RESPONSE=$(curl -L -s -w "HTTPSTATUS:%{http_code}\\n" -H "X-Gitlab-Event: Push Hook" -H 'X-Gitlab-Token: '$SECRET_KEY --insecure $line 2&gt;&amp;1) &amp;
          HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') &amp;
          HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') &amp;
  
          save_log "$HTTP_STATUS" "$HTTP_BODY" &amp;
  done &lt; $FILE_NAME
  </code></pre>
  
  <p>how i can run threading or make the loop fast in bash ? </p>