Can GNU parallel output stdout before the program has exited

gnu-parallel

echo 'echo "hello, world!";sleep 3;' | parallel

This command does not output anything until it has completed. Parallel's man page claims:

GNU parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially.

I guess the devil is in the phrasing: you get the same output as if you would run it normally, but not the output the same as if you would run it normally. I've looked for an option that will do this, for example --results /dev/stdout, but that does not work.

My use-case is seeing real-time progress output from the command that I'm running. It's not about how many tasks have completed, which parallel could display for me, but about the progress output of each command individually that I want to see.

I would use a bash loop (for i in $x; do cmd & done;) but I want to be able to stop all tasks with a single Ctrl+C, which parallel allows me to do.

Is it possible to do this in parallel? If not, is there another tool?

Best Answer

I think you're looking for --ungroup. The man page says:

--group  Group output. Output from each jobs is grouped 
         together and is only printed when the command is finished. 

         --group is the default. Can be reversed with -u.

-u of course is a synonym for --ungroup.

Related Question