LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   remove huge amount of files (https://www.linuxquestions.org/questions/linux-newbie-8/remove-huge-amount-of-files-4175427485/)

thetiger2003 09-16-2012 04:26 AM

remove huge amount of files
 
i have i directory that contains huge amount of files
i need to remove the old files until specific date
thx alot

Didier Spaier 09-16-2012 05:29 AM

To list the files which will be erased:
Code:

find <directory> -mtime +<number of days since the file was last modified>
Then to erase it:
Code:

find <directory> -mtime +<number of days since the file was last modified>|xargs /bin/rm -f
BE VERY CAREFUL not to erase files unexpectedly or inadvertently and keep in mind that the "file" command is recursive... So adapt if the directories has sub-directories where you don't want to erase files.

To know more: "man find"

thetiger2003 09-16-2012 05:58 AM

what the usage of |xargs /bin/rm -f ??

pixellany 09-16-2012 06:05 AM

|xargs** says: "Take the results of the previous command and use them in the following command, as if they had been entered with the latter."


**I don't think you can have xargs without a pipe (|) feeding it.

thetiger2003 09-16-2012 06:19 AM

thx alot


All times are GMT -5. The time now is 08:29 PM.