* Compare directories the most efficient way
@ 2005-10-25 3:08 Meino Christian Cramer
2005-10-25 3:27 ` Jean Chalard
0 siblings, 1 reply; 4+ messages in thread
From: Meino Christian Cramer @ 2005-10-25 3:08 UTC (permalink / raw)
To: zsh-users
Hi,
(using Linux)
I have a problem and dont know, whether zsh includes some "extras" to
solve it.
There are two identical directory trees with binary stuff in it but
with a different prefix for example:
/home/user/onetree/.
and
/home/user/theothertree/.
Unfortunately the files in there have "invalid" filenames with spaces
and other ASCII- and not-so-ASCII-traps (german Umlauts for example).
It is not possible to rename the files with detox, since then other
things will no longer work.
I want to binary-compare all files of one tree with those
corresponding ones of the other tree. For this purpose I choose the
"cmp" command (but if there are others more zshy ones...I have no
problem to use those.... :O).
The problem is to write a function/routine/script or whatever to do
that job. Everything tried result in errors like:
This : file not found
is : file not found
one : file not found
file : file not found
with : file not found
spaces : file not found
.bz2 : file not found
I tried "find <path> -ls | cut -b 69- " as a source for escaped filenames
in a for/do/done-loop but it failed the same way as mentioned above.
Is there any way out? :)
Thank you very much for any help in advance.
Keep zshing!
Meino
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compare directories the most efficient way
2005-10-25 3:08 Compare directories the most efficient way Meino Christian Cramer
@ 2005-10-25 3:27 ` Jean Chalard
2005-10-25 8:45 ` Vincent Lefevre
0 siblings, 1 reply; 4+ messages in thread
From: Jean Chalard @ 2005-10-25 3:27 UTC (permalink / raw)
To: Meino Christian Cramer; +Cc: zsh-users
> There are two identical directory trees with binary stuff in it but
> with a different prefix for example:
> /home/user/onetree/.
> and
> /home/user/theothertree/.
I think I may have missed something here, because I can't see why something like
for i in onetree/**/*; do cmp -- "$i" "${i/onetree/theothertree}"; done
...wouldn't work.
It wouldn't split the filenames on spaces, and I don't think any ascii
or non-ascii bizarreness would affect that kind of thing.
> The problem is to write a function/routine/script or whatever to do
> that job. Everything tried result in errors like:
>
> This : file not found
> is : file not found
> one : file not found
> file : file not found
> with : file not found
> spaces : file not found
> .bz2 : file not found
>
> I tried "find <path> -ls | cut -b 69- " as a source for escaped filenames
> in a for/do/done-loop but it failed the same way as mentioned above.
As I see it this is most likely caused by the sh_word_split option set
(which you probably *really* don't want most of the time), and the
absence of any quoting mark.
--
J
"Toi, je te trouve pas la même tête que sur la page précédente" -- Wakamiya
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compare directories the most efficient way
2005-10-25 3:27 ` Jean Chalard
@ 2005-10-25 8:45 ` Vincent Lefevre
2005-10-25 23:54 ` Meino Christian Cramer
0 siblings, 1 reply; 4+ messages in thread
From: Vincent Lefevre @ 2005-10-25 8:45 UTC (permalink / raw)
To: zsh-users
On 2005-10-25 12:27:28 +0900, Jean Chalard wrote:
> > There are two identical directory trees with binary stuff in it but
> > with a different prefix for example:
> > /home/user/onetree/.
> > and
> > /home/user/theothertree/.
>
> I think I may have missed something here, because I can't see why
> something like
>
> for i in onetree/**/*; do cmp -- "$i" "${i/onetree/theothertree}"; done
>
> ...wouldn't work.
Several problems:
* If there's a file in theothertree that doesn't exist in onetree,
you won't see the corresponding error.
* I think you should use something like onetree/**/*(D^/) to include
files starting with a dot, but not directories.
* If there are special files (symlinks...), this is even more
complicated.
"diff -r" (possibly with -q) from the diffutils is probably a better
choice.
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compare directories the most efficient way
2005-10-25 8:45 ` Vincent Lefevre
@ 2005-10-25 23:54 ` Meino Christian Cramer
0 siblings, 0 replies; 4+ messages in thread
From: Meino Christian Cramer @ 2005-10-25 23:54 UTC (permalink / raw)
To: vincent; +Cc: zsh-users
From: Vincent Lefevre <vincent@vinc17.org>
Subject: Re: Compare directories the most efficient way
Date: Tue, 25 Oct 2005 10:45:27 +0200
> On 2005-10-25 12:27:28 +0900, Jean Chalard wrote:
> > > There are two identical directory trees with binary stuff in it but
> > > with a different prefix for example:
> > > /home/user/onetree/.
> > > and
> > > /home/user/theothertree/.
> >
> > I think I may have missed something here, because I can't see why
> > something like
> >
> > for i in onetree/**/*; do cmp -- "$i" "${i/onetree/theothertree}"; done
> >
> > ...wouldn't work.
>
> Several problems:
> * If there's a file in theothertree that doesn't exist in onetree,
> you won't see the corresponding error.
> * I think you should use something like onetree/**/*(D^/) to include
> files starting with a dot, but not directories.
> * If there are special files (symlinks...), this is even more
> complicated.
>
> "diff -r" (possibly with -q) from the diffutils is probably a better
> choice.
Hi,
yes, indeed....there are dotted files in there...even directories are
dotted...and not found with the pattern above.
I didn't choose diff, since I wanted a more common (or is "general"
the better choice?) solution in case of haveing the task to feed two
corresponding files to a program, which "does" something with that
input.
keep zshing!
Meino
> --
> Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
> Work: CR INRIA - computer arithmetic / SPACES project at LORIA
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-10-25 23:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-25 3:08 Compare directories the most efficient way Meino Christian Cramer
2005-10-25 3:27 ` Jean Chalard
2005-10-25 8:45 ` Vincent Lefevre
2005-10-25 23:54 ` Meino Christian Cramer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).