I just stumbled over

exec 1> >(logger -s -t $(basename $0)) 2>&1

which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).

I am wondering why the 1> is necessary. It seems necessary because exec >(logger -s -t test) 2>&1 fails due to

bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied

Omitting 1> is however what I'd do intuitively because exec >[some redirection target] already should be sufficient for the redirection according to the question linked above. 2>&1 then redirects the stderr to stdout as usual.

I'm using bash 4.4.19.

  • 2
    @mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that >(...) means that. I'd accept that as an answer. – Karl Richter Dec 28 '18 at 10:24

It is necessary (the extra >, not the 1, 1> could be simply written >). The >(...) process substitution will expand to something like /dev/fd/13 (a file name), and then > will redirect the standard output into it. Thence > >(...).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.