LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-14-2010, 05:11 AM   #1
AlbertJJ
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Rep: Reputation: 0
Question Deleting million files


Hi all,

There are millions of files in many directories. Wherenver i try rm * or find or use xargs, they say 'argument list too long' and exit.

How can i deleted files in a directory with so many files without deleting the directory itself.
 
Old 11-14-2010, 05:43 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
You didn't post any commands.

Try:

Code:
find directory -type f -print0 | xargs -0 rm -f
directory is the top directory you want to clear of files.
 
1 members found this post helpful.
Old 11-14-2010, 05:44 AM   #3
wargus
Member
 
Registered: Mar 2010
Location: Switzerland
Distribution: Slackware
Posts: 97

Rep: Reputation: 13
Did you try out

Code:
find -type f -print0 | xargs -0 rm
in that directory?


Edit: too slow
 
1 members found this post helpful.
Old 11-14-2010, 05:48 AM   #4
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Its the -r option in rm that is giving the problem.
You use find to delete the files one at a time.

eg:
find . -name 'spam-*' | xargs rm

You can set the find command options to go recursively through directories.

http://www.simplehelp.net/2009/02/18...oo-long-error/

In case that is what you've already tried, a more careful approach:
http://www.linuxquestions.org/questi...quired-817009/
... you should be able to modify the script for your files.

Last edited by Simon Bridge; 11-14-2010 at 05:50 AM.
 
1 members found this post helpful.
  


Reply

Tags
delete, files


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
LXer: What's the best way to move 60 million files from one Windows server to another? - Linux LXer Syndicated Linux News 0 09-25-2010 04:50 AM
maximum files per directory for optimal access speed when having 13 million files andrew777 Linux - Server 3 04-27-2009 02:30 PM
LXer: Wikimedia to Sloan: Thanks a million, thanks a million, thanks a million LXer Syndicated Linux News 0 03-26-2008 02:50 PM
3 million files in a DIR swiswire Debian 3 09-02-2007 01:30 AM
10 million files on Linux? dcabbar Linux - General 11 07-12-2005 11:38 AM


All times are GMT -5. The time now is 02:31 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration