Ubuntu – Delete the parent folder keeping the contained files

filesystem

Is it possible that if I have this:

/folder1/folder2/folder3
/folder1/folder2/file1.txt

Can I delete folder2 but keep its content?

So the result would look like:

/folder1/folder3
/folder1/file1.txt

Best Answer

cd /folder1/folder2/
mv * ../
cd ../

Now check the contents of the folder:

ls

Then use this command to delete the directory. It is completely safe since it will only delete empty directories:

rmdir folder2/