I want to delete all files that have the pattern of "*.zip" in the directory /home/mydir and all sub-directories.
rm -Rf /home/mydir/*.zip
produces an error. What did I overlook?
Thanks.....
what's the error you get?
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org]On Behalf Of Todd Cary Sent: Friday, August 04, 2006 5:05 PM To: centos@centos.org Subject: [CentOS] Computer 1A question
I want to delete all files that have the pattern of "*.zip" in the directory /home/mydir and all sub-directories.
rm -Rf /home/mydir/*.zip
produces an error. What did I overlook?
Thanks.....
From: Seán O Sullivan Sent: August 4, 2006 17:10
Todd Cary wrote:
I want to delete all files that have the pattern of "*.zip" in the directory /home/mydir and all sub-directories.
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Or: find /home/mydir -name "*.zip" -type f -exec rm {} ;
Regards, Hugh
-- Hugh E Cruickshank, Forward Software, www.forward-software.com
On Fri, 4 Aug 2006 at 5:17pm, Hugh E Cruickshank wrote
From: Seán O Sullivan Sent: August 4, 2006 17:10
Todd Cary wrote:
I want to delete all files that have the pattern of "*.zip" in the directory /home/mydir and all sub-directories.
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Or: find /home/mydir -name "*.zip" -type f -exec rm {} ;
To complete the discussion, the first form should be faster, as it will only spawn 1 rm command rather than one for every result of 'find'. This can make a big difference if a lot of results are expected.
This one worked like a champ:
find /home/mydir -name "*.zip" -type f -exec rm {} ;
Whereas this one produced an error:
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Many thanks!
Todd
Joshua Baker-LePain wrote:
On Fri, 4 Aug 2006 at 5:17pm, Hugh E Cruickshank wrote
From: Seán O Sullivan Sent: August 4, 2006 17:10
Todd Cary wrote:
I want to delete all files that have the pattern of "*.zip" in the directory /home/mydir and all sub-directories.
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Or: find /home/mydir -name "*.zip" -type f -exec rm {} ;
To complete the discussion, the first form should be faster, as it will only spawn 1 rm command rather than one for every result of 'find'. This can make a big difference if a lot of results are expected.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Sat, 5 Aug 2006 at 7:48am, Todd Cary wrote
This one worked like a champ:
find /home/mydir -name "*.zip" -type f -exec rm {} ;
Whereas this one produced an error:
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
For completeness' sake, what was the error?
Joshua -
The error is
rm: Too few arguments
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Todd
Joshua Baker-LePain wrote:
On Sat, 5 Aug 2006 at 7:48am, Todd Cary wrote
This one worked like a champ:
find /home/mydir -name "*.zip" -type f -exec rm {} ;
Whereas this one produced an error:
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
For completeness' sake, what was the error?
On Sat, 5 Aug 2006 at 8:27am, Todd Cary wrote
Joshua Baker-LePain wrote:
On Sat, 5 Aug 2006 at 7:48am, Todd Cary wrote
This one worked like a champ:
find /home/mydir -name "*.zip" -type f -exec rm {} ;
Whereas this one produced an error:
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
For completeness' sake, what was the error?
The error is
rm: Too few arguments
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Odd -- that WORKSFORME.
Joshua Baker-LePain wrote:
On Sat, 5 Aug 2006 at 8:27am, Todd Cary wrote
Joshua Baker-LePain wrote:
On Sat, 5 Aug 2006 at 7:48am, Todd Cary wrote
This one worked like a champ:
find /home/mydir -name "*.zip" -type f -exec rm {} ;
Whereas this one produced an error:
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
For completeness' sake, what was the error?
The error is
rm: Too few arguments
find /home/mydir -name "*.zip" -type f -print0 | xargs -0 rm
Odd -- that WORKSFORME.
WORKSFORME2 -- One time in a row. Like this:
[rj@mavis ~]$ find /home/rj/Desktop/Trash -name "*.zip" -type f -print0 | xargs -0 file /home/rj/Desktop/Trash/ezphotocalendarcreatorv3.25serialcat.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/ezphotocalendarcreatorv3-2.25serialcat.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/6664037a0e353d9311481cb6cf777cc3041.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/ezphotocalendarcreatorv3-5.25serialcat.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/ezphotocalendarcreatorv3-4.25serialcat.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/ezphotocalendarcreatorv3-1.25serialcat.zip: Zip archive data, at least v2.0 to extract /home/rj/Desktop/Trash/9864037a0e353d9311481cb6cf777cc3041.zip: Zip archive data, at least v2.0 to extract
So, we have 7 files; remove 'em
[rj@mavis ~]$ find /home/rj/Desktop/Trash -name "*.zip" -type f -print0 | xargs -0 rm
Check to see they're gone and the "file" command gets uptight
[rj@mavis ~]$ find /home/rj/Desktop/Trash -name "*.zip" -type f -print0 | xargs -0 file Usage: file [-bcikLnNsvz] [-f namefile] [-F separator] [-m magicfiles] file... file -C -m magicfiles Try `file --help' for more information.
Now, try to remove the already-removed files: [rj@mavis ~]$ find /home/rj/Desktop/Trash -name "*.zip" -type f -print0 | xargs -0 rm rm: too few arguments Try `rm --help' for more information.
The error looks a tad familiar.
[rj@mavis ~]$