Results 1 to 16 of 16
-
03-30-2005, 08:37 AM #1Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
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
-
03-30-2005, 08:38 AM #2Web Hosting Master
- Join Date
- Feb 2004
- Posts
- 2,197
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 •
-
03-30-2005, 08:45 AM #3Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
I didnt see any errors but it didnt remove the files
-
03-30-2005, 08:51 AM #4Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
would rm -f *.tmp work?
-
03-30-2005, 08:57 AM #5Web Hosting Master
- Join Date
- Feb 2004
- Posts
- 2,197
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 •
-
03-30-2005, 08:59 AM #6Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
Yeah I would need it to go into sub directories since there are a few hundred of these files.
-
03-30-2005, 10:06 AM #7Web Hosting Guru
- Join Date
- Mar 2001
- Location
- California
- Posts
- 332
find . -name *.tmp -exec rm -f {} \;
-
03-30-2005, 10:09 AM #8Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
I got the error:
find: missing argument to `-exec'
-
03-30-2005, 10:11 AM #9Web Hosting Guru
- Join Date
- Mar 2001
- Location
- California
- Posts
- 332
Did you copy the entire line.... with the \; on the end?
-
03-30-2005, 10:13 AM #10Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
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
-
03-30-2005, 10:18 AM #11Retired Moderator
- Join Date
- May 2004
- Location
- Toronto, Canada
- Posts
- 5,105
I think you need another space between {} and \;
CloudNexus Technology Services
Managed Services
-
03-30-2005, 10:19 AM #12Web Hosting Guru
- 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 {} \;
-
03-30-2005, 10:20 AM #13Disabled
- Join Date
- Dec 2003
- Posts
- 1,941
Thanks, no error this time, but when I use the command locate .wav.tmp.wav again I see all of the files still remain.
-
03-30-2005, 10:25 AM #14Web Hosting Guru
- Join Date
- Mar 2001
- Location
- California
- Posts
- 332
Do you have permission to remove them?
-
03-30-2005, 10:27 AM #15Web Hosting Master
- 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.
-
03-30-2005, 10:32 AM #16Web Hosting Guru
- 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.