![比较两个文件后,diff 会列出所有不同的行吗?](https://linux22.com/image/1566909/%E6%AF%94%E8%BE%83%E4%B8%A4%E4%B8%AA%E6%96%87%E4%BB%B6%E5%90%8E%EF%BC%8Cdiff%20%E4%BC%9A%E5%88%97%E5%87%BA%E6%89%80%E6%9C%89%E4%B8%8D%E5%90%8C%E7%9A%84%E8%A1%8C%E5%90%97%EF%BC%9F.png)
diff file1 file2
是否列出和diff file1 file2
之间的所有不同行,包括所有不可打印的字符?file1
file2
答案1
是的,它将打印两个文件之间的所有不同行,除非该文件中的任何一个都包含二进制字符。
示例:
使用空格:
echo 'difftest ' > diff1
echo 'difftest' > diff2
diff diff1 diff2
输出:
1c1
< difftest
---
> difftest
和新队:
echo 'difftest ' > diff1
echo 'difftest\n' > diff2
diff diff1 diff2
输出:
1c1,2
< difftest
---
> difftest
>
和二进制字符(无效的):
echo 'difftest\0' > diff1
echo 'difftest' > diff2
diff diff1 diff2
输出:
Binary files diff1 and diff2 differ