Deleting many files from a directory

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.
--
M=E1rio Gamito
Administra=E7=E3o de sistemas e desenvolvimento
Netual - Multim=E9dia e Telecomunica=E7=F5es, Lda.
Rua Jo=E3o Afonso, N=BA1
3800-198 Aveiro - Portugal
Tel. +351 234 371 431 / Fax. +351 234 371 438
E-mail: gamito [at] netual.pt
www.netual.pt
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
gamito [ Do, 23 Dezember 2004 10:40 ] [ ID #550520 ]

Re: Deleting many files from a directory

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 [at] bitgnome.net
Apartment 724 http://nipsy.bitgnome.net/
Bryan, Texas, 77802-4481 AIM/Yahoo: texasnipsy ICQ: 66971617
(979)575-3193 MSN: nipsy [at] 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+++ [at] 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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Nipper [ Do, 23 Dezember 2004 10:59 ] [ ID #550521 ]

Re: Deleting many files from a directory

--==========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
<gamito [at] netual.pt> 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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
harry_b [ Do, 23 Dezember 2004 11:13 ] [ ID #550522 ]

Re: Deleting many files from a directory

On 23 Dec 2004, harry_b [at] 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 [at] bitgnome.net
Apartment 724 http://nipsy.bitgnome.net/
Bryan, Texas, 77802-4481 AIM/Yahoo: texasnipsy ICQ: 66971617
(979)575-3193 MSN: nipsy [at] 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+++ [at] 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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Nipper [ Do, 23 Dezember 2004 11:48 ] [ ID #550523 ]

Re: Deleting many files from a directory

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
> 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.
> --
> M=E1rio Gamito
> Administra=E7=E3o de sistemas e desenvolvimento
> Netual - Multim=E9dia e Telecomunica=E7=F5es, Lda.
> Rua Jo=E3o Afonso, N=BA1
> 3800-198 Aveiro - Portugal
> Tel. +351 234 371 431 / Fax. +351 234 371 438
> E-mail: gamito [at] netual.pt
> www.netual.pt
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin=
"
> in
> the body of a message to majordomo [at] 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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hal Wigoda [ Do, 23 Dezember 2004 13:08 ] [ ID #550803 ]

Re: Deleting many files from a directory

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
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

--
-------
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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Gustavo Guillermo [ Sa, 25 Dezember 2004 00:00 ] [ ID #552509 ]

Re: Deleting many files from a directory

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
> 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
>
>

--
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 [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
John Julian [ Fr, 24 Dezember 2004 19:39 ] [ ID #552510 ]

Re: Deleting many files from a directory

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 <glynn [at] gclements.plus.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Glynn Clements [ Do, 30 Dezember 2004 12:25 ] [ ID #559496 ]

Re: Deleting many files from a directory

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 <glynn [at] gclements.plus.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Glynn Clements [ Do, 30 Dezember 2004 12:26 ] [ ID #559497 ]
Linux » gmane.linux.admin » Deleting many files from a directory

Vorheriges Thema: Retrieval
Nächstes Thema: search all man pages