I am creating .patch file from diff diff -u $i /tmp/b/${i#/tmp/a/} > /tmp/patch/$j.patch
and I want to ask how can I change the names of files in header of eac开发者_开发百科h patch file. Now I have /tmp/a/...
and I want a/...
Thank you
AFAIK there is no direct option for this in diff
. When applying your diff with patch use -p <num>
option to strip the paths. In your case -p2
would give the desired result.
Maybe I don't understand, but if you were just to start your process while "sitting" at /tmp
providing diff
relative path - wouldn't it just work? Seems to work for me
(p.s. didn't know what your outer loop or the diff between $i & $j are, so used my own example with a FLAT tree)
cd /tmp
for i in a/*; do
diff -u "${i}" "b/${i#a/}" > "/tmp/patch/${i#a/}.patch"
done
You could also use sed
or such to change the text in each patch file. And then use diff
to verify the changes. And if you get it wrong, you get to figure out the output of diff applied to diff output, what fun :)
精彩评论