bug-coreutils
[Top][All Lists]
Advanced

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

Re: doubt on mv [moving dir using mv]


From: Bob Proulx
Subject: Re: doubt on mv [moving dir using mv]
Date: Fri, 28 Dec 2007 15:13:49 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

parinay wrote:
>                              # mkdir test test1
>                              # mv test1 test
>                              # ls test/
>                              test1
>                              #

All normal and expected.

> If I try the same operation from X interface it fails with a proper error
> message. Might be the API there be handling this differently. But isn't mv
> from command line supposed to fail in above scenario (saying dir exists )?

If the target of the mv command is a directory then the source
arguments are moved into the target directory.  That is the defined
behavior of the mv command.  (The same is also true for cp too.)

See the coreutils info documentation for this synopsis:

     [...] if the last file is a directory and the `--no-target-directory'
     (`-T') option is not given, `mv' moves each SOURCE file to the
     specified directory, using the SOURCEs' names.

See the standards documentation for more information.

  http://www.opengroup.org/onlinepubs/009695399/utilities/mv.html

  [...] mv shall move each file named by a source_file operand to a
  destination file in the existing directory named by the target_dir
  operand [...] The destination path for each source_file shall be the
  concatenation of the target directory, a single slash character, and
  the last pathname component of the source_file. This second form is
  assumed when the final operand names an existing directory.

Bob




reply via email to

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