2009-06-13 71 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