我有一个shell脚本,需要在其中判断两个文件是否包含相同的数据.我对很多文件都这样做,在我的脚本中,diff
命令似乎是性能瓶颈.
这是一句话:
diff -q $dst $new > /dev/null
if ($status) then ...
有没有一种更快的方法来比较文件,也许是一种自定义算法,而不是默认的diff
?
我有一个shell脚本,需要在其中判断两个文件是否包含相同的数据.我对很多文件都这样做,在我的脚本中,diff
命令似乎是性能瓶颈.
这是一句话:
diff -q $dst $new > /dev/null
if ($status) then ...
有没有一种更快的方法来比较文件,也许是一种自定义算法,而不是默认的diff
?
我相信cmp
将在第一个字节差处停止:
cmp --silent $old $new || echo "files are different"