How to execute a bash script in parallel for each line ? Actually, I will be tailing to log file and for each line found, I want to execute script in background something like below:tailf logfile.log | grep 'patternline' | while read line ; do     bash scriptname.sh $line & ; doneI would like to know, how to perform above using xargs (OR any other suitable method) parallely and also how to limit processes..Thanks in advance.
parallel processing using xargs
linux;bash;xargs;parallelism
You'd like to read the xargs manual and look up the -L and the -P flags in there.tail -f logfile.log | grep 'patternline' |xargs -P 4 -L 1 bash scriptname.shThis will execute at most four instances of the command at a time (-P 4), and with one line of input for each invocation (-L 1).Add -t to xargs to see what gets executed.