Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 Adapted to question being edited by the OP.
source | link

Your command needs to print a new-line to cause the pipe to process it.

test1(){ echo "testing-one"; sleep 100; }
test2(){ echo -n "testing-two"; sleep 100; }

test1| sed 's"s/^/'$$(date -u +%Z-%Y-%m-%d-%T)'/'"

When the function (serving as command proxy) tested is test1, it does emit a newline. When used, a line is emitted immediately, even if the command itself has not finished (sleep 100).

When the function test2 is used (edit the third line), the line is not emitted till the whole command line is finished.

Your command needs to print a new-line to cause the pipe to process it.

test1(){ echo "testing-one"; sleep 100; }
test2(){ echo -n "testing-two"; sleep 100; }

test1| sed 's/^/'$(date -u +%Z-%Y-%m-%d-%T)'/'

When the function (serving as command proxy) tested is test1, it does emit a newline. When used, a line is emitted immediately, even if the command itself has not finished (sleep 100).

When the function test2 is used (edit the third line), the line is not emitted till the whole command line is finished.

Your command needs to print a new-line to cause the pipe to process it.

test1(){ echo "testing-one"; sleep 100; }
test2(){ echo -n "testing-two"; sleep 100; }

test1| sed "s/^/$(date -u +%Z-%Y-%m-%d-%T)/"

When the function (serving as command proxy) tested is test1, it does emit a newline. When used, a line is emitted immediately, even if the command itself has not finished (sleep 100).

When the function test2 is used (edit the third line), the line is not emitted till the whole command line is finished.

1
source | link

Your command needs to print a new-line to cause the pipe to process it.

test1(){ echo "testing-one"; sleep 100; }
test2(){ echo -n "testing-two"; sleep 100; }

test1| sed 's/^/'$(date -u +%Z-%Y-%m-%d-%T)'/'

When the function (serving as command proxy) tested is test1, it does emit a newline. When used, a line is emitted immediately, even if the command itself has not finished (sleep 100).

When the function test2 is used (edit the third line), the line is not emitted till the whole command line is finished.