linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Deleting many files from a directory
@ 2004-12-23  9:40 Mário Gamito
  2004-12-23  9:59 ` Mark Nipper
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Mário Gamito @ 2004-12-23  9:40 UTC (permalink / raw)
  To: linux-admin

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ário Gamito
Administração de sistemas e desenvolvimento
Netual - Multimédia e Telecomunicações, Lda.
Rua João Afonso, Nº1
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23  9:40 Deleting many files from a directory Mário Gamito
@ 2004-12-23  9:59 ` Mark Nipper
  2004-12-23 10:13 ` harry_b
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Mark Nipper @ 2004-12-23  9:59 UTC (permalink / raw)
  To: M?rio Gamito; +Cc: linux-admin

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23  9:40 Deleting many files from a directory Mário Gamito
  2004-12-23  9:59 ` Mark Nipper
@ 2004-12-23 10:13 ` harry_b
  2004-12-23 10:48   ` Mark Nipper
  2004-12-23 12:08 ` Hal Wigoda
  2004-12-25 12:08 ` Gustavo Guillermo Perez
  3 siblings, 1 reply; 9+ messages in thread
From: harry_b @ 2004-12-23 10:13 UTC (permalink / raw)
  To: Mário Gamito; +Cc: linux-admin

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

Hi,

--On Thursday, December 23, 2004 09:40:12 +0000 Mário Gamito 
<gamito@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------

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23 10:13 ` harry_b
@ 2004-12-23 10:48   ` Mark Nipper
  2004-12-30 11:25     ` Glynn Clements
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Nipper @ 2004-12-23 10:48 UTC (permalink / raw)
  To: harry_b; +Cc: M?rio Gamito, linux-admin

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23  9:40 Deleting many files from a directory Mário Gamito
  2004-12-23  9:59 ` Mark Nipper
  2004-12-23 10:13 ` harry_b
@ 2004-12-23 12:08 ` Hal Wigoda
  2004-12-30 11:26   ` Glynn Clements
  2004-12-25 12:08 ` Gustavo Guillermo Perez
  3 siblings, 1 reply; 9+ messages in thread
From: Hal Wigoda @ 2004-12-23 12:08 UTC (permalink / raw)
  To: Mário Gamito; +Cc: linux-admin

do a loop

for i in filenames*
do
rm $i
done

On Dec 23, 2004, at 3:40 AM, Mário 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ário Gamito
> Administração de sistemas e desenvolvimento
> Netual - Multimédia e Telecomunicações, Lda.
> Rua João Afonso, Nº1
> 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
>
>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-25 12:08 ` Gustavo Guillermo Perez
@ 2004-12-24 18:39   ` John Julian
  0 siblings, 0 replies; 9+ messages in thread
From: John Julian @ 2004-12-24 18:39 UTC (permalink / raw)
  To: Gustavo Guillermo Perez; +Cc: Mário Gamito, linux-admin


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ário Gamito escribió:
> > 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
> 
> 

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23  9:40 Deleting many files from a directory Mário Gamito
                   ` (2 preceding siblings ...)
  2004-12-23 12:08 ` Hal Wigoda
@ 2004-12-25 12:08 ` Gustavo Guillermo Perez
  2004-12-24 18:39   ` John Julian
  3 siblings, 1 reply; 9+ messages in thread
From: Gustavo Guillermo Perez @ 2004-12-25 12:08 UTC (permalink / raw)
  To: Mário Gamito, linux-admin

El Jueves 23 Diciembre 2004 15:40, Mário Gamito escribió:
> 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23 10:48   ` Mark Nipper
@ 2004-12-30 11:25     ` Glynn Clements
  0 siblings, 0 replies; 9+ messages in thread
From: Glynn Clements @ 2004-12-30 11:25 UTC (permalink / raw)
  To: Mark Nipper; +Cc: harry_b, Mário Gamito, linux-admin


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@gclements.plus.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Deleting many files from a directory
  2004-12-23 12:08 ` Hal Wigoda
@ 2004-12-30 11:26   ` Glynn Clements
  0 siblings, 0 replies; 9+ messages in thread
From: Glynn Clements @ 2004-12-30 11:26 UTC (permalink / raw)
  To: Hal Wigoda; +Cc: Mário Gamito, linux-admin


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@gclements.plus.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-12-30 11:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-23  9:40 Deleting many files from a directory Mário Gamito
2004-12-23  9:59 ` Mark Nipper
2004-12-23 10:13 ` harry_b
2004-12-23 10:48   ` Mark Nipper
2004-12-30 11:25     ` Glynn Clements
2004-12-23 12:08 ` Hal Wigoda
2004-12-30 11:26   ` Glynn Clements
2004-12-25 12:08 ` Gustavo Guillermo Perez
2004-12-24 18:39   ` John Julian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).