LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2012, 04:26 AM   #1
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Rep: Reputation: 0
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
 
Old 09-16-2012, 05:29 AM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2 on Lenovo Thinkpad W520
Posts: 7,164

Rep: Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272
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"

Last edited by Didier Spaier; 09-16-2012 at 05:49 AM. Reason: I wrote "newer" instead of "older"...
 
Old 09-16-2012, 05:58 AM   #3
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
what the usage of |xargs /bin/rm -f ??
 
Old 09-16-2012, 06:05 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
|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.
 
Old 09-16-2012, 06:19 AM   #5
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Original Poster
Rep: Reputation: 0
thx alot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why needs the Upgrade to 17 a huge amount of data? JZL240I-U Fedora 6 08-08-2012 03:07 AM
copying a huge amount of small files, on a live system xxxx Linux - General 12 04-15-2008 02:53 AM
Huge amount of "PHP Notice:" -> huge logs Braynid Linux - Software 4 03-18-2008 06:35 AM
Move huge amount of folders with bash alexweb Linux - Newbie 4 10-27-2006 04:06 AM
Huge amount of stuff needs to be listed but how? Totoro Linux - Newbie 2 03-20-2004 02:10 AM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration