bug-coreutils
[Top][All Lists]
Advanced

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

Re: question for cp tools


From: Bob Proulx
Subject: Re: question for cp tools
Date: Fri, 4 Mar 2005 20:57:49 -0700
User-agent: Mutt/1.5.6+20040907i

Jim Meyering wrote:
> Right.  My motivation for adding this `feature' was to prevent
> `mv a/* b/* dir' from destroying (silently!) user data.  By the
> same token, a successful invocation of `cp a/* b/* dir' might well
> be followed by rm -rf a b.

I know this is one of the features that you really like.  So I have
not said anything previously.  But I would have to file this as being
one of the most annoying features to have been added in recent years.

I often have cases where I have duplicate files here and there in a
directory tree.  For various reasons I want to move them to the
archive.  If they are named the same they have the same contents so I
only want to keep exactly one copy of them.  So I want

  mv */*/foo ../ARCHIVE/
  mv $(find . -name foo -print)../ARCHIVE/

to move those files to the target directory.  But of course with the
duplicate check in place that fails.  So then I started using a for
loop so that it would be different mv commands.

  for f in */*/foo; do mv $f ../ARCHIVE/

That works but is a lot of typing.  If the -f option forced the move
then I would be happy with that.  The documentation explicitly says it
will overwrite files.

     -f, --force
          do not prompt before overwriting (equivalent to --reply=yes)

  mv -f */*/foo ../ARCHIVE/  # does not force

But of course that does not turn this behavior off.  So actually I use
the for loop most of the time.  Finger memory and all of that.

> It's be nice to fix POSIX.

I would rather see the previous behavior restored.

> Here's the NEWS item from fileutils-4.1.1 (November 3, 2001):
> 
>   * mv (likewise for cp), now fails rather than silently clobbering one of
>       the source files in the following example:
>       rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c

(Don't read too much sarcasm into this next statement.)
I am hoping there are no plans to make this fail.

  touch foo bar
  mv foo bar

Because currently that also silently clobbers files.  But that is just
the way I like it!

Bob




reply via email to

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