Delete the parent folder keeping all content

Rakib

I want to delete my parent directory but keep all of its content. Currently my directory structure

$ /usermanagement/usermanagement/file1

After deleting my parent directory I want to see like bellow structure

$ /usermanagement/file1
muhammad

May be I didn't understand your question properly. But the answer of what I have gathered from your question is,

Assuming you are in current directory, which name is nested and parent directory name is test.

$ cp -Rp . ../;cd ../;rm -rf nested

Explanation


  1. cp -Rp . ../ - This will copy all files including directory, nested directory and hidden files. Where,

    • -R flag is used for "copy directories recursively"

    • -p is to "preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all",

    • . is for indicating of current directory as source

    • .. indicating as parent directory as destination.

  2. cd ../ - This will move you from current to parent directory

  3. rm -rf nested - This will remove all the files including directories, nested directories and hidden files.

Sources: Man page

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to delete all content of a folder?

From Dev

delete all the folders inside a parent folder

From Dev

PHP Delete all folder content without deleting root folder

From Dev

Moving folder content to parent folder

From Dev

delete a folder and its content

From Dev

Find and delete folder but not content

From Dev

How to delete all except for some specific folder under parent-folder

From Dev

How to delete all the folder except one folder and its content using command prompt?

From Dev

How to copy a folder by overwriting an existing folder and delete all the old content in Linux?

From Dev

delete folder for all users on Mac

From Dev

how to delete all directories in a folder

From Dev

SQLite - How to delete parent row while keeping the child/children rows?

From Dev

Rails 4+ Best practices: Delete parent while keeping children

From Dev

GIT: Moving all content of a parent/subfolder to parent/

From Dev

Delete empty subfolders, keep parent folder

From Dev

Delete empty subfolders, keep parent folder

From Dev

Redirect a content of the directory to another directory in parent folder

From Dev

How can I delete the "sheet" node keeping its content intact?

From Dev

How can I delete the "sheet" node keeping its content intact?

From Dev

Delete files from a folder with changing content

From Dev

Cannot delete folder - Content seems to be nested recursively

From Dev

delete subfolders and files without deleting parent folder and child folder?

From Dev

How to delete all files in a directory, keeping sub-directories intact

From Dev

Move all files within subfolders to parent folder

From Dev

How to move all subdirectories into the parent folder in bash?

From Dev

Delete all hidden files in folder and subfolders

From Dev

How to delete all files in folder XXX

From Dev

Delete all in folder except the filename in list

From Dev

VB.Net Delete all files in folder

Related Related

  1. 1

    Is it possible to delete all content of a folder?

  2. 2

    delete all the folders inside a parent folder

  3. 3

    PHP Delete all folder content without deleting root folder

  4. 4

    Moving folder content to parent folder

  5. 5

    delete a folder and its content

  6. 6

    Find and delete folder but not content

  7. 7

    How to delete all except for some specific folder under parent-folder

  8. 8

    How to delete all the folder except one folder and its content using command prompt?

  9. 9

    How to copy a folder by overwriting an existing folder and delete all the old content in Linux?

  10. 10

    delete folder for all users on Mac

  11. 11

    how to delete all directories in a folder

  12. 12

    SQLite - How to delete parent row while keeping the child/children rows?

  13. 13

    Rails 4+ Best practices: Delete parent while keeping children

  14. 14

    GIT: Moving all content of a parent/subfolder to parent/

  15. 15

    Delete empty subfolders, keep parent folder

  16. 16

    Delete empty subfolders, keep parent folder

  17. 17

    Redirect a content of the directory to another directory in parent folder

  18. 18

    How can I delete the "sheet" node keeping its content intact?

  19. 19

    How can I delete the "sheet" node keeping its content intact?

  20. 20

    Delete files from a folder with changing content

  21. 21

    Cannot delete folder - Content seems to be nested recursively

  22. 22

    delete subfolders and files without deleting parent folder and child folder?

  23. 23

    How to delete all files in a directory, keeping sub-directories intact

  24. 24

    Move all files within subfolders to parent folder

  25. 25

    How to move all subdirectories into the parent folder in bash?

  26. 26

    Delete all hidden files in folder and subfolders

  27. 27

    How to delete all files in folder XXX

  28. 28

    Delete all in folder except the filename in list

  29. 29

    VB.Net Delete all files in folder

HotTag

Archive