Find the answer to your Linux question:
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 ...
  1. #1
    Just 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 .

    Code:
     find /bla/* -mtime +8 | rm
    but it didnt work ...
    rm: too few arguments
    Try `rm --help' for more information.

  2. #2
    Linux 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 {} \;

  3. #3
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    Or like this...

    Code:
    find /bla/* -mtime +8 | xargs rm *
    Regards

    Regards

    Andutt

  4. #4
    Linux 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:
    Code:
    find /bla/* -mtime +8 -print0 | xargs -0 rm
    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.

  5. #5
    Just Joined!
    Join Date
    Apr 2003
    Posts
    20

    thanks

    ok , it worked ..
    thanks for the tips pals ..
    peace ,

    Smokie :P

  6. #6
    Just 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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...