Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought I was moving a sub directory up a level so that it would be a sibling of its parent. But it's now completely invisible. Is it gone?

Here's the command I used:

mv parentdir/mydir ../mydir
share|improve this question
up vote 2 down vote accepted

I figured it out. All I did was change the name so that it started with the .., and that made it hidden to the "ls" command.

share|improve this answer
    
Ah.... so you accidentally ran "mv parentdir/mydir ..mydir" not "mv parentdir/mydir ../mydir" (no slash after the dots) I'll guess. Good find! Thanks for updating the question. – pbr Nov 25 '09 at 20:24

If ../mydir already existed, you've moved it into ../mydir/mydir. Otherwise it's at ../mydir.

In a command like this, paths are relative to the current working directory (unless the path starts with /, in which case it's an absolute path). So your command didn't tell mv to make mydir a sibling of parentdir, you told it to make mydir a sibling of the working directory.

What you wanted to do was one of these two:

# make parentdir/mydir to be a sibling of parentdir
$ mv parentdir/mydir ./
$ ls -1
parentdir
mydir

# make parentdir/mydir to be a sibling of parentdir
$ ( cd parentdir ; mv mydir ../ )
$ ls -1
parentdir
mydir
share|improve this answer

When running a command like cp, scp, mv and the like, where the second argument is a directory, it's safest to end it with a /., so that both you and the command know that you are looking for a directory there. For example, instead of doing this:

$ mv /opt/foo /temp

I would do:

$ mv /opt/foo /temp/.

and get the error message:

mv: cannot move `/opt/foo' to `/temp/.': No such file or directory

because, of course, I meant to type /tmp/.. Had I run the first command I would have silently -- and quite unintentionally -- renamed the directory.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .