'How can I get the stdout of each command and modify them in a linux bash script? [duplicate]

This question is kind of hard to formulate in one title.

I have a bash script that start in background 3 pythons scripts. Each script are printing stuff on stdout. Now as they are running in parallel, I can't tell precisely from which of the 3 script, a specific string printed is coming from.

So basically I want to know if there is a way to "catch" the stdout of each script, concatenate something like "script1:" in front of each line, then print the whole in the terminal.

Thanks



Solution 1:[1]

Something like this

./test1.py 2>&1 | sed -e '/^/'"test1"' /' &

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 warkruid