Deleting many files from a directory

Deleting many files from a directory

am 23.12.2004 10:40:12 von gamito

Hi,

When we have too many files in a directory, let's say thousands, we=20
cannot rm -f * on them. The system says there are too many files.
So, one must go through a tedious process of deleting by parts.

Is there a way to wipe them all at onde ?

Thank you.

Warm Regards.
--=20
M=E1rio Gamito
Administração de sistemas e desenvolvimento
Netual - Multim=E9dia e Telecomunicações, Lda.
Rua Jo=E3o Afonso, N=BA1
3800-198 Aveiro - Portugal
Tel. +351 234 371 431 / Fax. +351 234 371 438
E-mail: gamito@netual.pt
www.netual.pt
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 23.12.2004 10:59:17 von Mark Nipper

On 23 Dec 2004, M?rio Gamito wrote:
> When we have too many files in a directory, let's say thousands, we
> cannot rm -f * on them. The system says there are too many files.
> So, one must go through a tedious process of deleting by parts.
>
> Is there a way to wipe them all at onde ?

Multiple ways to do it really, but one would be:
---
find /path/to/delete -exec rm -f \{\} \;

--
Mark Nipper e-contacts:
4475 Carter Creek Parkway nipsy@bitgnome.net
Apartment 724 http://nipsy.bitgnome.net/
Bryan, Texas, 77802-4481 AIM/Yahoo: texasnipsy ICQ: 66971617
(979)575-3193 MSN: nipsy@tamu.edu

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GG/IT d- s++:+ a- C++$ UBL++++$ P--->+++ L+++$ !E---
W++(--) N+ o K++ w(---) O++ M V(--) PS+++(+) PE(--)
Y+ PGP t+ 5 X R tv b+++@ DI+(++) D+ G e h r++ y+(**)
------END GEEK CODE BLOCK------

---begin random quote of the moment---
"Suppose you were an idiot and suppose you were a member of
Congress. But I repeat myself."
-- Mark Twain
----end random quote of the moment----
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 23.12.2004 11:13:31 von harry_b

--==========0FB8F02B4010EB87FB1A==========
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

--On Thursday, December 23, 2004 09:40:12 +0000 M=E1rio Gamito=20
wrote:

> When we have too many files in a directory, let's say thousands, we
> cannot rm -f * on them. The system says there are too many files.
> So, one must go through a tedious process of deleting by parts.
>
> Is there a way to wipe them all at onde ?

To remove all files in all subdirectories do:

find /path/ -type f | xargs -n 50 rm

Thats much faster than 'find ...-exec...'

Cheers,
Harry

--

1024D/40F14012 18F3 736A 4080 303C E61E 2E72 7E05 1F6E 40F1 4012

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT/S dx s: a C++ ULS++++$ P+++ L+++$ !E W++ N+ o? K? !w !O !M
V PS+ PE Y? PGP+++ t+ 5-- X+ R+ !tv b++ DI++ D+ G e* h r++ y++
------END GEEK CODE BLOCK------

--==========0FB8F02B4010EB87FB1A==========
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFByppUfgUfbkDxQBIRAqTdAKCP1lJtg3Ncjcm6x84mGf943eL4FgCe OTll
d8UuSHmk9EhGwL16g+FHcYw=
=L8Xq
-----END PGP SIGNATURE-----

--==========0FB8F02B4010EB87FB1A==========--

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 23.12.2004 11:48:25 von Mark Nipper

On 23 Dec 2004, harry_b@mm.st wrote:
> To remove all files in all subdirectories do:
>
> find /path/ -type f | xargs -n 50 rm
>
> Thats much faster than 'find ...-exec...'

That can get a little strange though if files have spaces
or other strange characters in their names.

--
Mark Nipper e-contacts:
4475 Carter Creek Parkway nipsy@bitgnome.net
Apartment 724 http://nipsy.bitgnome.net/
Bryan, Texas, 77802-4481 AIM/Yahoo: texasnipsy ICQ: 66971617
(979)575-3193 MSN: nipsy@tamu.edu

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GG/IT d- s++:+ a- C++$ UBL++++$ P--->+++ L+++$ !E---
W++(--) N+ o K++ w(---) O++ M V(--) PS+++(+) PE(--)
Y+ PGP t+ 5 X R tv b+++@ DI+(++) D+ G e h r++ y+(**)
------END GEEK CODE BLOCK------

---begin random quote of the moment---
"All mail clients suck. This one just sucks less."
-- author of the Mutt e-mail client
----end random quote of the moment----
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 23.12.2004 13:08:24 von Hal Wigoda

do a loop

for i in filenames*
do
rm $i
done

On Dec 23, 2004, at 3:40 AM, M=E1rio Gamito wrote:

> Hi,
>
> When we have too many files in a directory, let's say thousands, we=20
> cannot rm -f * on them. The system says there are too many files.
> So, one must go through a tedious process of deleting by parts.
>
> Is there a way to wipe them all at onde ?
>
> Thank you.
>
> Warm Regards.
> --=20
> M=E1rio Gamito
> Administração de sistemas e desenvolvimento
> Netual - Multim=E9dia e Telecomunicações, Lda.
> Rua Jo=E3o Afonso, N=BA1
> 3800-198 Aveiro - Portugal
> Tel. +351 234 371 431 / Fax. +351 234 371 438
> E-mail: gamito@netual.pt
> www.netual.pt
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin=
"=20
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>

-----------------
Hal Wigoda

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 24.12.2004 19:39:27 von John Julian

your can also try:

for f in a b c d e f g h i j k l m n o p q r s t u v w x y z
do rm ${f}*
done

you might need to repeat for capitals and numbers.



On Sat, 25 Dec 2004, Gustavo Guillermo Perez wrote:

> El Jueves 23 Diciembre 2004 15:40, M=E1rio Gamito escribi=F3:
> > Hi,
> >
> > When we have too many files in a directory, let's say thousands, we
> > cannot rm -f * on them. The system says there are too many files.
> > So, one must go through a tedious process of deleting by parts.
> >
> > Is there a way to wipe them all at onde ?
> >
> > Thank you.
> >
> > Warm Regards.
> if is Just a directory, call rm with the name of the directory
> like that
> rm -rf /dirname
> where the r is for recursive, sometimes find hangs with more than 655=
35 files=20
> in a single directory in some older versions (I still using some ones=
).
>=20
> If you have a lot of folders with a lot of files, then:
>=20
> find -type d | while read dir; do rm -rf "$dir" ; done
>=20
> "" in $dir is for names with spaces.
>=20
>=20
> Mery Christmas
>=20
>=20

--=20
John Julian
Computer Geek
cell: 248-376-6364
pager: 800-621-4951

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 25.12.2004 00:00:06 von Gustavo Guillermo

El Jueves 23 Diciembre 2004 15:40, M=E1rio Gamito escribi=F3:
> Hi,
>
> When we have too many files in a directory, let's say thousands, we
> cannot rm -f * on them. The system says there are too many files.
> So, one must go through a tedious process of deleting by parts.
>
> Is there a way to wipe them all at onde ?
>
> Thank you.
>
> Warm Regards.
if is Just a directory, call rm with the name of the directory
like that
rm -rf /dirname
where the r is for recursive, sometimes find hangs with more than 65535=
files=20
in a single directory in some older versions (I still using some ones).

If you have a lot of folders with a lot of files, then:

find -type d | while read dir; do rm -rf "$dir" ; done

"" in $dir is for names with spaces.


Mery Christmas

--=20
-------
Gustavo Guillermo Perez
Compunauta uLinux
www.userver.tk

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 30.12.2004 12:25:02 von Glynn Clements

Mark Nipper wrote:

> > To remove all files in all subdirectories do:
> >
> > find /path/ -type f | xargs -n 50 rm
> >
> > Thats much faster than 'find ...-exec...'
>
> That can get a little strange though if files have spaces
> or other strange characters in their names.

Using:

find /path -type -f -print0 | xargs -0 -n 50 rm

will cope with filenames which contain whitespace.

--
Glynn Clements
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Deleting many files from a directory

am 30.12.2004 12:26:02 von Glynn Clements

Hal Wigoda wrote:

> do a loop
>
> for i in filenames*
> do
> rm $i
> done

Put quotes around the variable, i.e.:

rm "$i"

otherwise it won't handle filenames which contain whitespace.

Shell variables should always be quoted unless you actually want
values which contain whitespace to be split into multiple words.

--
Glynn Clements
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html