Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

<() is a new way to do I/O redirection, by which I mean it was introduced by I think the Korn shell in the early 1990s, which explains why you haven't heard of it. Also it isn't implementable on all Unixes.

The way it works is that if you say

    foo <(bar) -o >(baz) <(quuz)
foo sees them as command-line arguments, which might look like

    foo /dev/fd/3 -o /dev/fd/4 /dev/fd/5
and if it is clever enough to treat them as filenames and open them, then it will get the stdout of bar, the stdin of baz, and the stdout of quux, respectively.

The way this works is that the shell opens pipes to the other command lines first, then generates filenames for them.

I did not know that you could use it with other I/O redirections such as <!

As a bonus, the <() syntax means you can pipe even to and from commands that don't read from stdin or stdout. They must not, however, depend on the ability to seek.

My most common use for this is nonlinear pipe flow, e.g.

    diff -u <(sort -u file1) <(sort -u file2)
Hope this helps!


You bet it helps. Thanks for the great explanation!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: