是否可以在没有物理文件的情况下使用“diff”工具?像这样:
diff "hello" "hell"
答案 0 :(得分:23)
您可以使用特殊文件名-
:
# 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)