2009-06-13 70 views

回答

16

您可以通過使用特殊的文件名- diff的標準輸入與文件:

# diff the contents of the file 'some-file' with the string "foobar" 
echo foobar | diff - some-file 

使用bash,你也可以使用匿名命名管道(有點用詞不當)以區分兩條管道:

# diff the string "foo" with the string "baz" 
diff <(echo foo) <(echo baz) 

另請參閱How can you diff two pipelines with bash?

+0

++打我吧。 – guns 2009-06-13 23:04:53