I have the following while loop in a bash script however I would like to run these in parallel (an failing) can anyone point me in to the right direction please?
Thanks!
while read LINE; do
RAYID=$(echo "$LINE" | jq -r .rayId)
LINE="$(echo $LINE | sed 's/\([[:digit:]]\{13\}\)[[:digit:]]\{6\}/\1/g')"
args=( -XPUT "localhost:9200/els/logs/$RAYID?pipeline=geoip-els" -H "Content-Type: application/json" -d "$LINE" )
curl "${args[@]}" > /dev/null 2>&1
done <<< "$ELS_LOGS"
&if you want to run each curl command in the backgroundjqand an array to store the arguments. I might suggest trying to move more of the processing intojqas well, so that you have something likeecho "$ELS_LOGS" | jq '...' | while read -r rayid line; do args=(...); curl ...; done.