bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Small change in find


From: James Youngman
Subject: Re: Small change in find
Date: Tue, 10 May 2005 17:11:16 +0100
User-agent: Mutt/1.3.28i

On Tue, May 10, 2005 at 09:36:09AM -0400, Taliver Heath wrote:
> Actually, I think I now know what you were suggesting-- using the
> printf format specifiers as the "variable" in the find expression for
> modification:
> 
> Copy the backups of  .c files into directories named original-cfile-backups:
> 
> find -name '*.c~' -exec mkdir '{h}-cfiles-backups' \; -exec cp '{}' '{p%~}' \;
> 
> And, of course, without a specifier given, p would be assumed, so:
> {} is equivalent to {p} and {%~} is equivalent to {p%~}.

I would be more inclined to use {%p}, but if % introduces a format
specifier, it's hard to make use of the same symbol to introduce an
sh-style substitution.  Well, perhaps not hard to implement, but
certainly hard to document clearly.  

Could you have a think about what might be a sensible interface design
here?  I'm interested int he functionality and that the interface not
be altogether surprising to people whose expectations are formed by
familiarity with Unix; I'm less concerned that we specifically follow
the /bin/sh style of prefix and suffix handling.  It might be worth
looking at how GNU make does this sort of thign too.

> Or is this making find to icky? 

Well, it all depends on how sensible an interface we can come up with.
As for implementation, we'll see an ickiness reduction due to
refactoring -printf, but let's worry about how icky the mechanism is
to implement when we have a sensible plan. 


> 
> On 5/10/05, Taliver Heath <address@hidden> wrote:
> > Since the semicolon is required by POSIX, then it probably shouldn't
> > be changed to
> > avoid the problem you mentioned.  (I still think it would be convienient)
> > 
> > As to the extension that you found somewhat interesting, let me give a
> > concrete example:
> > 
> > "Rename every *~ file as *.bak"
> > 
> > find /home/me -type f -name "*~" -exec mv '{}' '{%~}.bak' \;
> > 
> > I am not sure how you would do this using the printf format, since it
> > doesn't have a way to strip arbitrary suffixes/prefixes from
> > filenames.  Perhaps some kind of combination between the two styles is
> > in order?
> > 
> > 

(I've corrected my email adddress in the below)

> > On 5/10/05, James Youngman <address@hidden> wrote:
> > > On Mon, May 09, 2005 at 01:09:42PM -0400, Taliver Heath wrote:
> > > > I haven't read any of the bugs/requests/etc, so please forgive me if
> > > > this is a common request.  I have often thought that with the find
> > > > command, the semicolon should be optional on a -exec or -ok command
> > > > when it is the last command in the line.  For instance:
> > > >
> > > > find /path -type f -exec ls -l '{}'
> > >
> > > The semicolon is required by the POSIX standard, of course.  I can
> > > see why this is convenient, but won't it just lead people to write
> > > scripts that don't work with other versions of find, or even with
> > > older versions of GNU find?
> > >
> > > > Also, I would be interest in addressing the '{}'-syntax, and expanding
> > > > this to include the bash %,%%,#,## rules.
> > >
> > > That's an interesting idea.  It's probably simpler though to make it
> > > understand the format directives already used by -printf, which would
> > > require a little refactoring.
> > >
> > > James.
> > >
> > >
> >




reply via email to

[Prev in Thread] Current Thread [Next in Thread]