Let's say I have a working directory:


I type a mv command that will affect the parent directory of the current working directory and the working directory itself:

mv .* /tmp/someDirectory

When executed, the command moves the content of both directories /home/userID and /home/userID/workingDirectory because .* is a match of the .. link in the current directory.

So far so good.

But, what I don't understand is why the files and directories are moved to the parent of the argument?

The files appear inside /tmp instead of /tmp/someDirectory

Can anybody throw some light?

OS is Solaris.


  • 1
    Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory ../* to /tmp/someDirectory/../* which is /tmp/*. – jimmij Sep 22 '18 at 3:28
  • Ah, so. When mv goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a ../* then it's being interpreted as: /tmp/someDirectory/../* which will point to /tmp because is using the .. link inside /tmp/someDirectory. Am I correct? – Aeross Sep 22 '18 at 3:58
  • 1
    I'm not sure about that interpretation. Can you verify the expansion of the glob with something like echo .* /tmp/someDirectory? – Sparhawk Sep 22 '18 at 4:18
  • I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here. – Aeross Sep 22 '18 at 4:35

Because basically the system is doing the following when using .*. renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV Thus it's moved to /tmp/workingDirectory instead of /tmp/narf

  • To be precise, given that the target is /tmp, the mv command probably first attempts your posted renameat() system call, which likely fails with errno set to EXDEV since /tmp is almost certainly on a different file system. The mv command will then copy the file(s), and if successful delete the original(s). – Andrew Henle Sep 23 '18 at 22:21
  • Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".." – c0t0d0s0 Sep 24 '18 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.