Results 1 to 6 of 6
Is it possible to delete all the files that appear in the find command's output , for example .. i tried this command in order to delete every file which ...
- 05-15-2003 #1Just Joined!
- Join Date
- Apr 2003
- Posts
- 20
is it possible to "rm" the find's output ?
Is it possible to delete all the files that appear in the find command's output , for example .. i tried this command in order to delete every file which has been modified more than 8 days ago
in /bla/ directory .
but it didnt work ...Code:find /bla/* -mtime +8 | rm
rm: too few arguments
Try `rm --help' for more information.
- 05-15-2003 #2Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Why of course. You can't pipe the output to rm. rm deletes files that it finds on its command line, not on its standard input. Try this instead:
Code:find /bla/* -mtime +8 -exec rm {} \;
- 05-15-2003 #3Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Or like this...
RegardsCode:find /bla/* -mtime +8 | xargs rm *
Regards
Andutt
- 05-15-2003 #4Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Yeah, but the problem with xargs is that it chokes on special characters. If you want to use xargs, at least do it like this:
By the way, you do _not_ want to do "xargs rm *", andutt! I think you'll see why if you look at it once more.Code:find /bla/* -mtime +8 -print0 | xargs -0 rm
- 05-15-2003 #5Just Joined!
- Join Date
- Apr 2003
- Posts
- 20
thanks
ok , it worked ..
thanks for the tips pals ..
peace ,
Smokie :P
- 05-02-2006 #6Just Joined!
- Join Date
- May 2006
- Posts
- 3
Wow... This thread helped me alot...
Got a ton of files off a mac user, and was crawling with shadow files...
so I used: "find */*/._* -print0 | xargs -0 rm"
I'm too lazy to make it automaticly crawl all dirs, it was mainly 2 subdirs in...


Reply With Quote
