0

We want two stdout streams - one for data another for metadata - instead of sending metadata to stderr - we could send it a 4th fd (3).

How would we do that? Here is a bad start:

 my_progam > <( exec<> 3 ) 3> file1 2> file2

so in the echo process, how can it write to 3? I am trying to open up a file descriptor using process substitution instead of a "real" file.

  • Please describe the source of the metadata, (i.e. a program, a file, or what), and the source of the data, (ditto). – agc May 10 at 1:25
  • 1
    yeah I guess it would look like this ( echo "foo" <&1 ; echo "bar" <&3 )> > ... I am not that good with bash, but you'd have a process that writes to two different file descriptors, one for stdout for data and then another which represents metadata, fd3 for metadata and fd2 for stderr – Alexander Mills May 10 at 1:27
  • 2
    A script would write to file descriptor 3 by using >&3 for redirecting the output. – larsks May 10 at 1:30
  • Yeah so it would look like ( echo "foo" >&1 ; echo "bar" >&3 ), so I have to questions, how can I create a process that listens for stdin and another file descriptor fd3 using bash? and how can I open a file descriptor inline using process substitution? – Alexander Mills May 10 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.