猿问

文件对比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
收到一只叮咚
浏览 413回答 2
2回答

qq_遁去的一_1

# ---------------------------------------- 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 }
随时随地看视频慕课网APP

相关分类

Java
我要回答