[lug] Process substitution.

David L. Anselmi anselmi at anselmi.us
Sun Sep 19 10:41:14 MDT 2010


I've recently found some uses for bash's process substitution (didn't think I would but what do I 
know?)  But it seems hard to tell whether it will work or not for different programs.  Does anyone 
know why some don't work?

For example, if I have programs a and b and I want to compare their output, these lines do the same 
thing:

   diff <(a) <(b)
   a > a.txt ; b > b.txt ; diff a.txt b.txt

But logrotate doesn't work like diff.  It takes a config file as an argument but won't read this:

   logrotate <(# code to generate config file here)

I plan to look at the source, but maybe someone already knows.

BTW, in zsh you can do <(), which uses a FIFO, or you can do =(), which uses a file.  I expect 
logrotate would work fine with the =() form.  But I don't have zsh where I've tried to use this.

Thanks!
Dave



More information about the LUG mailing list