Results 1 to 16 of 16
  1. #1

    Simple SSH command question please

    Hello, is there a command that will remove all files that end in the same extension? For example, I used the locate blah.tmp command to locate all of the files that end in .blah.tmp, is there a command that can remove them all at once as well? Thanks

  2. #2
    This command should work: find . | grep *.tmp | xargs rm -f
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support • Web Hosting • Reseller Hosting • Cloud/VPS Plans • Dedicated Servers •

  3. #3
    I didnt see any errors but it didnt remove the files

  4. #4
    would rm -f *.tmp work?

  5. #5
    Yes, rm -f *.tmp should work, but it won't go into sub directories...
    crucialparadigm - Affordable, Reliable, Professional :
    Web Hosting
    24/7 Support • Web Hosting • Reseller Hosting • Cloud/VPS Plans • Dedicated Servers •

  6. #6
    Yeah I would need it to go into sub directories since there are a few hundred of these files.

  7. #7
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    find . -name *.tmp -exec rm -f {} \;

  8. #8
    I got the error:

    find: missing argument to `-exec'

  9. #9
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    Did you copy the entire line.... with the \; on the end?

  10. #10
    Yes:

    root@blah [~]# find . -name *.wav.tmp.wav -exec rm -f {}\;
    find: missing argument to `-exec'
    root@blah [~]#

    oh yeah the real file extension is .wav.tmp.wav btw

  11. #11
    Join Date
    May 2004
    Location
    Toronto, Canada
    Posts
    5,105
    I think you need another space between {} and \;
    CloudNexus Technology Services
    Managed Services

  12. #12
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    You need a space between the } and \

    It wouldn't hurt to put quotes around your search string also.

    Just copy and paste this directly.

    find . -name "*.wav.tmp.wav" -exec rm -f {} \;

  13. #13
    Thanks, no error this time, but when I use the command locate .wav.tmp.wav again I see all of the files still remain.

  14. #14
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    Do you have permission to remove them?

  15. #15
    Join Date
    Mar 2004
    Location
    New Jersey
    Posts
    798
    Thats because you also need to run updatedb afterward. Bet if you go in and check those files, they aren't actually there.

  16. #16
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    Ahh... yes, if you are using locate to find them afterwards it is lying to you. The locate database may only get updated once per day depending on how you have it configured.

Posting Permissions

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