0

I would like to process STDERR with sed on the fly

A program gives me wrong information on STDERR, my goal is to correct that information.

So far I have tried this:

$ perl -e 'print STDERR "bar says that foo has to disappear"' 2> >(sed s/foo/.../)

Unfortunately, something weird happened, the output I get is this:

$ perl -e 'print STDERR "bar says that foo has to disappear"' 2> >(sed s/foo/.../)
$ bar says that ... has to disappear

You can notice my prompt is printed before the output. How to correct this?

nowox
  • 25,978
  • 39
  • 143
  • 293

1 Answers1

1

You might want to try an alternative way by using unnamed pipe:

( perl -e 'print STDERR "bar says that foo has to disappear"' 3>&1 1>&2- 2>&3- ) | sed 's/foo/.../g'

Prints the output before the prompt for me.