My project has the following structure
/project/config.mk
/project/dir1/config.mk -> ../config.mk
/project/dir2/config.mk -> ../config.mk
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.
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
Use find in the following way:
This option should skip following symbolic links. Use that command to locate your file before running diff.