Script to read file and run multiple jobs

I have a txt file

line1
line2
line3
$!/bin/sh
cat /tmp/lus.txt | while read line
do
esxcli storage vmfs unmap -u $lin -n 4000
done

this works but does in one line at a time.

how do I do all lines at once simutaeously?

#!/bin/sh
while read line
do
   esxcli storage vmfs unmap -u $line -n 4000 &
done < /tmp/lus.txt
wait     # (or not)

can you explain? what is wait for?

---------- Post updated at 09:18 AM ---------- Previous update was at 09:15 AM ----------

is this going to run all 30 lines at once?

esxcli storage vmfs unmap -u $line -n 4000 &

The wait command will not complete until all background processes for this shell have ended. This means your script will spawn all your 30 (or whatever) esxcli commands and then hang until they complete so you know when to carry on. If you don't want this to happen, simply remove the wait

Robin

does esxi support running & jobs in the bg?