user347221 Asked: 2019-04-15 17:08:36 +0800 CST2019-04-15 17:08:36 +0800 CST 2019-04-15 17:08:36 +0800 CST 使用 diff 比较两个命令的输出 772 如何使用diff来比较两个命令的输出? 我知道如何使用它来比较文件的内容和filename1命令的输出cmd2: cmd | diff filename - 我该如何做到,以便我可以有另一个命令,比如cmd1代替filename? 我正在使用破折号,它不支持进程替换。 diff stdout 2 个回答 Voted Best Answer Stephen Kitt 2019-04-15T23:32:33+08:002019-04-15T23:32:33+08:00 基于How to emulate Process Substitution in Dash? (感谢αғsнιη!),调整为dash: ( cmd1 | ( cmd2 | ( diff /dev/fd/3 /dev/fd/4 ) 4<&0 ) 3<&0 ) defdefred 2019-11-22T13:47:17+08:002019-11-22T13:47:17+08:00 简单的 :-) $ cat file1 | diff /dev/stdin /dev/stderr 2<< EOT > `cat file2` > EOT 2c2 < 2 --- > 4
基于How to emulate Process Substitution in Dash? (感谢αғsнιη!),调整为
dash
:简单的 :-)