Skip to main content
2 of 5
removed obsolete remark
Lesmana
  • 28.1k
  • 20
  • 85
  • 87

I don't know what text your book uses, but the bash manual is clear (if you're a little familiar with redirections already):

If |& is used, the standard error of command1 is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error is performed after any redirections specified by the command.

So if you don't want to mix standard output and standard error, you'll have to redirect standard output somewhere else. See How to grep standard error stream (stderr)?

{ ./script.sh 2>&1 >&3 | sed 's:^:\t:'; } 3>&1
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k