parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: confusion about using parallel to replace a for loop


From: Joe Sapp
Subject: Re: confusion about using parallel to replace a for loop
Date: Fri, 21 Jan 2022 08:44:00 -0900

On Fri, Jan 21, 2022 at 6:03 AM John <graysky@archlinux.us> wrote:
When I run the simple script below, initially, there is no output to the shell until the function finishes.  Is there a switch I can use for parallel so that the function outputs below the sleep command finishes?

#!/bin/bash
hash=( 1 2 3 4 5 6 7 8 9 )

getit() {
  echo "this is $1"
  sleep 1s
}

export -f getit
parallel -j 3 getit ::: "${hash[@]}"

Try `--line-buffer` or `--ungroup` as you prefer (the man page says `--group` is the default).

--
Joe Sapp

reply via email to

[Prev in Thread] Current Thread [Next in Thread]