Cannot redirect output from sed

You're running into an output buffering problem. sed normally buffers its output when not writing to a terminal, so nothing gets written to the file until the buffer fills up (probably every 4K bytes).

Use the -u option to sed to unbuffer output.

clock -sf 'S%A, %B %d. %I:%M %P' | sed -u 's/\b0\+\([0-9]\+\)/\1/g' > testfile

I was having the same problem while trying to redirect from a streaming output source.

You should use the -u (unbuffered) flag with sed and then PIPE the data instead of appending it with >> operator (>> locks the file and is blocking).

Instead doing the following works

someprogram | sed '/filter/' | tee myfile.txt