使差异忽略符号链接 [英] make diff to ignore symbolic link

查看:83
本文介绍了使差异忽略符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目具有以下结构

/project/config.mk
/project/dir1/config.mk -> ../config.mk
/project/dir2/config.mk -> ../config.mk

当我使用 diff 创建补丁文件, /project/config.mk 正确完成,但是两个符号链接出现了一些问题。它们都被视为新文件,diff部分是 config.mk 文件的全部内容。我试图找到 diff 选项来禁用以下符号链接,但是没有这样的选项。感谢所有建议。

When I used diff to create the patch file, the /project/config.mk was done correctly, but the two symbolic links got some problems. They were both treated as new files, the diff sections were the whole content of the config.mk file. I tried to find a diff option to disable following symbolic link, but there is no such option available. Any suggestions are appreciated.

根据Overbose的建议,我创建了此脚本。有用。谢谢大家花时间回答。

As Overbose's suggestion, I create this script. It works. Thank everyone for taking time answering.

#!/bin/sh -v
ori_dir=$1
new_dir=$2
patch_file=./patch_file
if [ -f ${patch_file} ]
then
        rm ${patch_file}
fi
ori_files=`cd ${ori_dir} ; find ./ -type f ! -type l`
for i in ${ori_files} ; do 
        if [ -f ${ori_dir}/$i ] 
        then
                if [ -f ${new_dir}/$i ]
                then
                        diff -rup ${ori_dir}/$i ${new_dir}/$i >> ${patch_file}
                fi
        fi
done


推荐答案

按以下方式使用查找:

find . ! -type l

此选项应跳过以下符号链接。在运行差异之前,使用该命令定位文件。

This option should skip following symbolic links. Use that command to locate your file before running diff.

这篇关于使差异忽略符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆