LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Empty a directory (https://www.linuxquestions.org/questions/linux-newbie-8/empty-a-directory-719674/)

fhsm 04-16-2009 04:46 PM

Empty a directory
 
What is the easiest way to empty a directory from the command line without removing the directory itself?

Long version:
I want to put a couple of aliases in my .bashrc to empty these folders I've got from downloading data from a few lab instruments.
For example ~/lab/instruments/epic-32-random-char-folder/

I've found that deleting the whole folder is a mistake. It saves me a number of steps in the download if those long named dirs are already in place. The software that analyzes the results copies out of the directories but doesn't clear them. Long story short these dirs must be manually cleared of about a thousand files between each use.

jay73 04-16-2009 04:49 PM

rm *? If the folder does not contain any subdirectories, that is.

billymayday 04-16-2009 05:22 PM

rm -rf ~/lab/instruments/epic-32-random-char-folder/*

fhsm 04-16-2009 11:19 PM

Quote:

Originally Posted by billymayday (Post 3511532)
rm -rf ~/lab/instruments/epic-32-random-char-folder/*

Thanks!


All times are GMT -5. The time now is 06:20 AM.