没有文件的差异 [英] Diff without files

查看:60
本文介绍了没有文件的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在没有物理文件的情况下使用 diff工具?像这样的东西:

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

diff "hello" "hell"


推荐答案

您可以使用特殊文件名-:

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

通过bash,您还可以使用匿名命名管道(有点用词不当) )来比较两个管道:

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)

另请参见如何用bash区分两个管道?

这篇关于没有文件的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆