Linux - Delete the contents of a directory

November 2016


I'm under linux and I cannot find the command to erase the contents of a folder without deleting the file read itself. So if someone could help me with this command Thanks! Rm-r deletes the folder too. So it's not the one I want. Thank you


You put yourself in the directory and do

rm -rf *  

Or you do

rm -rf your_directory/*  


Solved by cricx

Related :

This document entitled « Linux - Delete the contents of a directory » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.