Bash 文件比较
示例
if [[ $file1 -ef $file2 ]]; then echo "$file1 and $file2 are the same file" fi
“相同文件”意味着在适当位置修改其中一个文件会影响另一个文件。即使两个文件具有不同的名称,它们也可以是相同的,例如,如果它们是硬链接,或者它们是具有相同目标的符号链接,或者一个是指向另一个的符号链接。
如果两个文件具有相同的内容,但是它们是不同的文件(因此修改一个文件不会影响另一个文件),则将-ef它们报告为不同的文件。如果要逐字节比较两个文件,请使用该cmp实用程序。
if cmp -s -- "$file1" "$file2"; then echo "$file1 and $file2 have identical contents" else echo "$file1 and $file2 differ" fi
要生成易于理解的文本文件之间的差异列表,请使用该diff实用程序。
if diff -u "$file1" "$file2"; then echo "$file1 and $file2 have identical contents" else : # the differences between the files have been listed fi
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练