java - 文件对比Shell 求更好方案
本文介绍了java - 文件对比Shell 求更好方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
differ=$(diff -rq $1 $2| awk {'print $2,$3,$4'} );
for file in $differ
do
echo $file
done
$file 输出如下
/home/test/system/app.text
and
/home/vgg/system/app.text
/home/test/system/app1.text
and
/home/vgg/system/app2.text
in
/home/test/system:
app.txt
我想让其
vimdiff 旧文件 新文件
确认无误后
cp /home/test/system/app.txt /home/vgg/system/app.txt
如果是只是单独的某个文件有的话 in ...
cp /home/test/system/app.txt /home/vgg/system/app.txt
解决方案
# ---------------------------------------- Function ---------------------------------------- #
function checkFilesDiff()
{
# diff -c -a -b -r -q -P $1 $2
homeq=($(diff -rq $1 $2 | grep -Ff $3 | grep -Fvf $noGrep|awk {'print $2'} ));
mydir=($(diff -rq $1 $2 | grep -Ff $3 | grep -Fvf $noGrep|awk {'print $4'} ));
i=0
while [[ i -lt ${#homeq[@]} ]]; do
vimdiff ${mydir[i]} ${homeq[i]}
deploy_confirm " 修改确认 ${mydir[i]} ?"
if [ 1 != $? ]; then
let i++
continue;
fi
sleep 1
cp ${mydir[i]} ${homeq[i]}
let i++
done
}
这篇关于java - 文件对比Shell 求更好方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文