Diff
使用 diff 比較兩個命令的輸出
如何使用
diff
來比較兩個命令的輸出?我知道如何使用它來比較文件的內容和
filename1
命令的輸出cmd2
:cmd | diff filename -
我該如何做到,以便我可以有另一個命令,比如
cmd1
代替filename
?我正在使用破折號,它不支持程序替換。
基於How to emulate Process Substitution in Dash? (感謝αғsнιη!),調整為
dash
:( cmd1 | ( cmd2 | ( diff /dev/fd/3 /dev/fd/4 ) 4<&0 ) 3<&0 )
簡單的 :-)
$ cat file1 | diff /dev/stdin /dev/stderr 2<< EOT > `cat file2` > EOT 2c2 < 2 --- > 4