5 ms·
bash(?) thing I wish I'd discovered years earlier: diff <(command1) <(command2) instead of command1 > file1; command2 > file2; diff file1 file2; rm file1 file2
by ben0x539 13y ago
bash(?) thing I wish I'd discovered years earlier: diff <(command1) <(command2) instead of command1 > file1; command2 > file2; diff file1 file2; rm file1 file2
- gnaritas 13y agoYup, cool use of named pipes.
- tripa 13y agoNamed pipes are filesystem objects you create with mkfifo. What's in use here is more widely known as “process substitution”.
- gnaritas 13y agoWhich works by creating two named pipes and feeding them to diff and pumping your processes data into them. Process substitution is built on named pipes, they are the enabling mechanism that makes it work. Try this in a terminal: echo <(true) And you'll see the anonymous named pipe created by the subshell and passed to echo.