f



Creating patch files for selected files

Hi,

I would like to produce a recursive for 2 directories, but only for .c
and .h files in them. There's the -x and -X options to diff that I
know of, which would allow me to exclude items. But in my case there
are several other files like images, makefiles, Windows project files
inside the directories and I don't want them to be included in the
diff output. So selected inclusion would be much easier for me,
compared to that of exclusion. Any body knows how to do this?

Thanks
Jeenu
0
Jeenu
7/31/2008 11:24:01 AM
comp.unix.shell 15484 articles. 3 followers. Post Follow

3 Replies
665 Views

Similar Articles

[PageSpeed] 49

On Jul 31, 4:24=A0am, Jeenu <jee...@gmail.com> wrote:

> I would like to produce a recursive for 2 directories, but only for .c
> and .h files in them. ...  But in my case there
> are several other files like images, makefiles, Windows project files
> inside the directories and I don't want them to be included in the
> diff output.

1. cp from dir1 only .c & .h files to a tmp folder
2. cp from dir2 only .c & .h files to another tmp folder
3. diff the two tmp folders

Example (assume cygwin on Windows).

$ mkdir tmp
$ tar cf - `find dir1 -name '*.c' -o -name '*.h'` | (cd tmp; tar xf -)
$ tar cf - `find dir2 -name '*.c' -o -name '*.h'` | (cd tmp; tar xf -)

Now, you have tmp/dir1/  and tmp/dir2/ containing only .h & .c files.

$ cd tmp
$ diff --unified=3D3 -r dir1 dir2  > diff.log


0
Harry
7/31/2008 11:07:16 PM
Basically I was looking for a diff switch that would do a selective
inclusion. But seems like it's not there; and duplicating seems the
only way out.

Thanks
Jeenu

Harry wrote:
> On Jul 31, 4:24=EF=BF=BDam, Jeenu <jee...@gmail.com> wrote:
>
> > I would like to produce a recursive for 2 directories, but only for .c
> > and .h files in them. ...  But in my case there
> > are several other files like images, makefiles, Windows project files
> > inside the directories and I don't want them to be included in the
> > diff output.
>
> 1. cp from dir1 only .c & .h files to a tmp folder
> 2. cp from dir2 only .c & .h files to another tmp folder
> 3. diff the two tmp folders
>
> Example (assume cygwin on Windows).
>
> $ mkdir tmp
> $ tar cf - `find dir1 -name '*.c' -o -name '*.h'` | (cd tmp; tar xf -)
> $ tar cf - `find dir2 -name '*.c' -o -name '*.h'` | (cd tmp; tar xf -)
>
> Now, you have tmp/dir1/  and tmp/dir2/ containing only .h & .c files.
>
> $ cd tmp
> $ diff --unified=3D3 -r dir1 dir2  > diff.log
0
Jeenu
8/1/2008 12:37:03 AM
Jeenu wrote...

>Basically I was looking for a diff switch that would do a selective
>inclusion. But seems like it's not there; and duplicating seems the
>only way out.

If you are a developer, you might want to download Gnu DiffUtils
and hack the codes yourself.


0
harryooopotter
8/1/2008 12:58:17 AM
Reply: