Diff without files

◇◆丶佛笑我妖孽 提交于 2019-12-05 11:51:19

问题


Is it possible to use the "diff" tool without having physical files? Something like this:

diff "hello" "hell"

回答1:


You can diff standard input with a file by using the special filename -:

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

With bash, you can also use anonymous named pipes (a bit of a misnomer) to diff two pipelines:

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

See also How can you diff two pipelines with bash?.



来源:https://stackoverflow.com/questions/991722/diff-without-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!