Ubuntu – command output redirection using ‘-< <( … )'

bashredirectsyntax

I needed to extract a shasum. This works, but can anyone explain why?

sed 's/^.*= //' -< <(openssl dgst -sha256 filename)

I'm familiar with the $( ) construct, but can't find docs for <( ), coupled with -<, which I assume is redirecting to the sed STDIN.

I know there are easier ways, but this construct eludes me.

Best Answer

The

<(openssl dgst -sha256 filename)

construct is a process substitution. It creates a file (or FIFO) behind the scenes and passes its name back to the command sequence.

< 

is a regular file redirection, redirecting the contents of the behind-the-scenes file to stdin and

-

is a placeholder recognized by sed to indicate that its input is coming from stdin.

Since sed is perfectly capable of reading from files, the -< seems unnecessary in this context;

sed 's/^.*= //' <(openssl dgst -sha256 filename)

should work just as well.