In this short post, we will learn to delete all the directories (folders) and keep the file as it is. This means deleting all the directories and not removing the files available in a particular location.
- Got to the main directory
- Use the command:
sudo rm -r */
- That’s it.
Let’s say you were trying to delete all the folders inside backup folder then go to the backup folder and use the command mentioned in step 2.
This deletes all the folders available inside a backup folder and keeps all the files present.