I wanted to move one level up the entire content of a directory (with all subfolders)

cd /dir/subdir
mv * /dir
cd ..
rm -R subir/

In /dir I have all folders and subfolders but they are empty. What did I do inappropriately?

Filesystem is BTRFS, I tried btrfs restore with no success.

Any help would be appreciated.

  • Do you have an alias for mv? Run type -a mv Feb 10, 2023 at 10:57
  • What were the contents of /dir and /dir/subdir before the mv command, and were any of these paths symbolic links? Also, did you have names in /dir that also existed under /dir/subdir before the mv command? When you say you "tried btrfs restore", what did you do exactly? Could you also let us know the actual pathnames that were involved, in case these are known to be special.
    – Kusalananda
    Feb 10, 2023 at 11:35

1 Answer 1


Let's look at what you did. I'm assuming all commands are standard tools that have not been tweaked in any way. (Check with type cd, type mv, and type rm. If any say they are aliased we need to know this. For example mv is aliased to 'mv -i' is something we need to know, but cd is a shell builtin or rm is /bin/rm is fine.)

  1. cd /dir/subdir

    Move to absolute path in filesystem. Assuming there were no errors reported you're now in /dir/subdir.

  2. mv * /dir

    Move everything visible in this directory to the absolute directory /dir. Assuming there were no files with names starting with - (as you forgot the --) and no errors were reported, all files and directories that were in /dir/subdir are now in /dir.

    Files (and subdirectories, if any) were moved, not copied, so file contents will not have been touched or changed in any way unless /dir/subdir is on a different filesystem to /dir.

  3. cd ..

    Either depending on your shell or providing that subdir wasn't a symbolic link to another part of the filesystem, and that no errors were reported, you should now be in /dir.

    To be absolutely certain what directory you're in, use pwd -P.

  4. rm -R subir/

    This command should probably have failed. But perhaps you meant rm -R subdir, in which case the directory subdir and any remaining contents will have been removed.

    You could have used rmdir subdir to remove the directory, allowing the system to warn you if it was unexpectedly not empty.

If the files are empty at this point and you had no errors with any of the commands you entered, then they were all empty before you started.

You must log in to answer this question.

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