8 ms·
Can also use comm <flags> <(command 1) <(command 2) To use the output of a command as input. This also works with diff and other commands.
by partycoder 8y ago
Can also use
comm <flags> <(command 1) <(command 2)
To use the output of a command as input.
This also works with diff and other commands.
- TheDong 8y agoMore accurately, it can be used for any command which expects a file and doesn't do anything too weird in reading it (e.g. doesn't seek to the beginning and read it again) The '<( ... )' is just giving the path to that command's stdout as a file descriptor. $ ls <(echo hi) /proc/self/fd/11 $ vi <(echo hi) # opens vi with 'hi' as the contents
- therein 8y agoThank you. I was just thinking of looking into how it was implemented.
- lloeki 8y agoIt is called "process substitution", and can work the other way around: http://www.tldp.org/LDP/abs/html/process-sub.html http://www.tldp.org/LDP/abs/html/process-sub.html With fish: https://fishshell.com/docs/current/commands.html#psub https://fishshell.com/docs/current/commands.html#psub But there it only works one way: https://github.com/fish-shell/fish-shell/issues/1786 https://github.com/fish-shell/fish-shell/issues/1786
- scintill76 8y agoNote that this is a bash feature; other shells may have different syntax.
- hawski 8y agoIt's the same in ksh at least, so one is covered in the BSDs. It could be also implemented as a separate tool, but not as convenient, because of additional quoting - I did once.
- hawski 8y agoI use it in my frugal SSG project [0] to remove HTML files for every removed source file. It's great to use it this way as it doesn't use temp files. [0] https://gist.github.com/hadrianw/060944011acfcadd889d937b960a5a1f https://gist.github.com/hadrianw/060944011acfcadd889d937b960...