[Linux-disciples] delete a whole lot of files

Adam Rosi-Kessel adam at rosi-kessel.org
Wed Feb 7 13:44:29 EST 2007


First, I would really recommend not doing any massive operations with
rm. In fact, you might just try an "echo" first to see what it's going
to do, e.g.,:

find /home/church -iname '*.jpg' -print0 |xargs -i0 echo rm "{}"

and make sure the output is as desired. (You probably want to pipe the
whole thing into less if there are > 100,000 files).

Second, your .aptitude is under your home directory, and apparently was
created when running as sudo, hence the owner is root:root. find wants
to look in there because you're starting at that directory, but can't
when you aren't root. You could just 'chown -R church:church
/home/church/.aptitude', which would fix the permission denied error,
but has nothing to do with what you're trying to accomplish.

Third, I'm not sure why you're getting the argument too long error, but
try this instead:

find /home/church/(whatever directory) -iname '*.jpg' \
		-exec cp '{}' /home/church/(some other directory) ';'

On 2/7/2007 1:35 PM, Karl Sokol wrote:
> My fault.  I obviously don't need it to look into .aptitude.  Why is it
> trying to anyhow?  I definitely do not want to recursively delete all jpegs.
> 
> church at ubuntu:~$ find /home/church -iname '*.jpg' -print0 |xargs -i0 rm
> '{}'
> find: /home/church/.aptitude: Permission denied
> xargs: argument line too long
> church at ubuntu:~$ sudo find /home/church -iname '*.jpg' -print0 |xargs
> -i0 rm '{}'
> Password:
> xargs: argument line too long
> church at ubuntu:~$ sudo sh -c "find /home/church -iname '*.jpg' -print0
> |xargs -i0 rm '{}'"
> xargs: argument line too long
> church at ubuntu:~$
> 
> 
> On 2/7/07, *Stephen R Laniel* <steve at laniels.org
> <mailto:steve at laniels.org>> wrote:
> 
>     On Wed, Feb 07, 2007 at 12:26:48PM -0600, Karl Sokol wrote:
>     > church at ubuntu:~$ sudo find /home/church -iname '*.jpg' -print0
>     |xargs -i0 rm '
>     > {}'
>     > Password:
>     > xargs: argument line too long
> 
>     It's likely that the sudo is messing you up. Do you need to
>     be running sudo? If you don't, take it out; if you do, do
> 
>     sudo sh -c "find /home/church -iname '*.jpg' -print0 |xargs -i0 rm
>     '{}'"
> 
>     --
>     Stephen R. Laniel
>     steve at laniels.org <mailto:steve at laniels.org>
>     Cell: +(617) 308-5571
>     http://laniels.org/
>     PGP key: http://laniels.org/slaniel.key
> 
>     -----BEGIN PGP SIGNATURE-----
>     Version: GnuPG v1.4.1 (GNU/Linux)
> 
>     iD8DBQFFyhqyHa1lzVGot+YRAkemAJ9+BfZX0Zyv3TPpPk9pxc4FQvD8TgCfcYql
>     I8AYjnUj2RB4Y8s8HFHV0qM=
>     =aq7Q
>     -----END PGP SIGNATURE-----
> 
>     _______________________________________________
>     Linux-disciples mailing list
>     Linux-disciples at lists.bostoncoop.net
>     <mailto:Linux-disciples at lists.bostoncoop.net>
>     http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
> 
> 
> 
> 
> -- 
> Grace and Peace,
> 
> Rev. Karl Sokol
> Franklin Grove UMC
> 211 N. Spring
> Franklin Grove, IL 61031
> 
> If you have a talent, that's God's gift to you. If you use that talent,
> that's your gift to God.
>                                                                                             --
> Red Skelton
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples




More information about the Linux-disciples mailing list