On Tue, Dec 14, 2021 at 5:45 PM Mark E. Fuller <mark.e.ful...@gmail.com> wrote: > > > It's such a small thing, but I really enjoyed being privy to this > question and discussion today. > > On 14/12/2021 17:21, Daniel Shahaf wrote: > > אורי wrote on Tue, 14 Dec 2021 07:44 +00:00: > >> Actually I prefer the "<(..)" method, because sometimes I want to compare 2 > >> commands: > >> > >> diff <(pip freeze | sort) <(cat requirements.txt | sort) > >> > > > > Consider s/diff/comm -12/. > > > >> Or even use cat and echo to add a specific line to one of the outputs. If I > >> want the result to be completely null. For example to run in crontab and > >> send me mail whether it's not null. > > > > Careful here. By default, cron jobs run not under your login shell but > > under /bin/sh, and it's possible the latter doesn't support «<(…)» even > > if the former does. > > Out of curiosity I asked the internet: > https://unix.stackexchange.com/questions/159513/what-are-the-shells-control-and-redirection-operators > > Looks like < as a redirect is POSIX-compliant, but as soon as it's > <(...) it's not a redirect anymore but instead a process substitution > which is implemented in BASH, ZSH, etc.: > https://www.gnu.org/software/bash/manual/bash.html#Process-Substitution > https://zsh.sourceforge.io/Intro/intro_7.html > > Nice to learn a new trick - I probably would have just redirected to a > temp file instead of the compact solution discussed today.
If we are heading in this direction, may I remind of another, likely POSIX-compliant (didn't check), more "traditional" way, that still does not require (much) I/O, at least on any reasonably-modern *nix (perhaps e.g. not including cygwin etc. - again, didn't check): $ mkfifo pipe1 $ mkfifo pipe2 $ command1 > pipe1 & $ command2 > pipe2 & - These are now blocked, waiting in the background until someone reads from the pipes $ diff pipe1 pipe2 - After 'diff' finishes reading, command1 and command2 will finish too. - On a job-controlling shell, you'll get some messages about this. $ rm pipe1 pipe2 Best regards, -- Didi _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il