LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-04-2010, 11:31 PM   #1
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Rep: Reputation: 32
Question What to do when rm does not bc of too many files?


I got a crazy question asking if you go in to a directory filled with a ton of files and you try to remove them but rm complains there are too many files what do you do? (I know - such an everyday occurrence.. why don't I know!)
 
Old 03-04-2010, 11:34 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Remove them in chunks ..? 'rm a*' 'rm b*' ...

<edit>Could also try combining 'find' with 'xargs rm'</edit>
 
Old 03-04-2010, 11:45 PM   #3
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
After thinking about it I wonder if you could not just move them all to a folder and try to rm -rf the folder. But then they might have said it was the temp folder and you can move them because they are encrypted.

Do you know for certain the xargs thing works?

Something like:

Find -name /tmp * | xargs rm -f
 
Old 03-04-2010, 11:55 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Yeah... it has for me in the past
 
Old 03-04-2010, 11:57 PM   #5
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
Ok that is officially in my crazy interview questions file then....
 
Old 03-05-2010, 05:59 AM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
xargs is the best way, the most efficient one.

You might want to research into this however:

Code:
find /path/to -print0 | xargs -0 rm
You don't really need a -name or -iname to remove all the files. And using nulls as separators ensure that a funky file name won't break the thing.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need to rsync only selected files (--files-from) also need to delete files on dest. ? BrianK Linux - General 5 10-22-2009 09:52 PM
ntfs hard drive mounted. but doesnt show all files , tar files ataomega Linux - Software 1 08-28-2009 12:47 PM
in copy files or ls files the command want to invert select some files how to?? hocheetiong Linux - Newbie 3 06-27-2008 06:32 AM
converting a doc/ppt Windows files in html files under linux env agrosu Programming 7 02-23-2006 03:07 PM
How to filter files in files and files which are in a sub-directory with "grep"? Piero Linux - Newbie 9 08-29-2003 02:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:17 AM.

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
Open Source Consulting | Domain Registration