* Deleting many files with rm
@ 2000-08-03 4:00 andrew.rycroft
2000-08-03 4:00 ` Eckhardt Wallmeroth
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: andrew.rycroft @ 2000-08-03 4:00 UTC (permalink / raw)
Hi,
I am trying to delete files (with rm * ) from a directory which
contains many files. I get the following error messages :-
ksh: /sbin/rm: arglist too long
Is there any other way of doing this other than writing a script to
delete the files a*, b*, c* etc. ?
What is the maximum no. of files I can delete ?
I also hit a similar limitation with tar !
Appreciate any input.
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-03 4:00 Deleting many files with rm andrew.rycroft
@ 2000-08-03 4:00 ` Eckhardt Wallmeroth
2000-08-03 4:00 ` Tony Verhulst
2000-08-04 4:00 ` David Schmitt
2000-08-03 4:00 ` Jeff Wilson
` (2 subsequent siblings)
3 siblings, 2 replies; 13+ messages in thread
From: Eckhardt Wallmeroth @ 2000-08-03 4:00 UTC (permalink / raw)
this is a general restriction for the length of a argument list which can be
passed from one process to its childs.
See 'man xargs' ; for your rm problem 'ls | xargs rm' is a solution.
Eckhardt
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-03 4:00 ` Eckhardt Wallmeroth
@ 2000-08-03 4:00 ` Tony Verhulst
2000-08-04 4:00 ` David Schmitt
1 sibling, 0 replies; 13+ messages in thread
From: Tony Verhulst @ 2000-08-03 4:00 UTC (permalink / raw)
When asking O/S questions PLEASE specify the release version. For V4x,
Eckhardt is correct in that there is a limit to the length of the
argument list. For versions V5.0 and above,\x03this restriction has been
removed and kernel space for arguments is allocated dynamically and you
should not hit this problem.
As a side note, some standards test suites actually depend the
limitation of kernel argument space and will fail on V5.0 and above. A
run time configurable argument "exec_disable_arg_limit" was created to
disable dynamic arg space allocation so the tests would pass. Run:
sysconfig -q proc
to see your setting (V5.0 and above)
Tony V.
Kernel Group
1%
sysconfig -q proc
proc:
max_proc_per_user = 64
max_threads_per_user = 256
per_proc_stack_size = 8388608
max_per_proc_stack_size = 33554432
per_proc_data_size = 134217728
max_per_proc_data_size = 1073741824
max_per_proc_address_space = 4294967296
per_proc_address_space = 4294967296
executable_stack = 0
autonice = 0
autonice_time = 600
autonice_penalty = 4
open_max_soft = 4096
open_max_hard = 4096
ncallout_alloc_size = 8192
round_robin_switch_rate = 0
sched_min_idle = 0
give_boost = 1
maxusers = 512
num_wait_queues = 512
num_timeout_hash_queues = 512
enhanced_core_name = 0
enhanced_core_max_versions = 16
exec_disable_arg_limit = 0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting many files with rm
2000-08-03 4:00 ` Eckhardt Wallmeroth
2000-08-03 4:00 ` Tony Verhulst
@ 2000-08-04 4:00 ` David Schmitt
1 sibling, 0 replies; 13+ messages in thread
From: David Schmitt @ 2000-08-04 4:00 UTC (permalink / raw)
You could also use "find" with the -exec option to do your filename
processing. "man find" will bootstrap you.
Dave Schmitt
"Eckhardt Wallmeroth" <ewallmeroth@de.lhsgroup.com> wrote in message
news:8mbept$64tqe$1@ID-41025.news.cis.dfn.de...
> this is a general restriction for the length of a argument list which can
be
> passed from one process to its childs.
> See 'man xargs' ; for your rm problem 'ls | xargs rm' is a solution.
>
> Eckhardt
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting many files with rm
2000-08-03 4:00 Deleting many files with rm andrew.rycroft
2000-08-03 4:00 ` Eckhardt Wallmeroth
@ 2000-08-03 4:00 ` Jeff Wilson
2000-08-04 4:00 ` hin-tak.leung@bt.com
2000-08-17 4:33 ` Josef Faulkner
3 siblings, 0 replies; 13+ messages in thread
From: Jeff Wilson @ 2000-08-03 4:00 UTC (permalink / raw)
If you're trying to remove all the files from a directory why not
remove the directory itself with "rm -r dirname", then recreate it with
"mkdir dirname" ?
--
Jeff Wilson
andrew.rycroft@intrinsitech.com wrote in article
<8mbaa1$b09$1@nnrp1.deja.com>...
| Hi,
|
| I am trying to delete files (with rm * ) from a directory which
| contains many files. I get the following error messages :-
|
| ksh: /sbin/rm: arglist too long
|
| Is there any other way of doing this other than writing a script to
| delete the files a*, b*, c* etc. ?
|
| What is the maximum no. of files I can delete ?
|
| I also hit a similar limitation with tar !
|
| Appreciate any input.
|
| Thanks
|
|
|
| Sent via Deja.com http://www.deja.com/
| Before you buy.
|
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-03 4:00 Deleting many files with rm andrew.rycroft
2000-08-03 4:00 ` Eckhardt Wallmeroth
2000-08-03 4:00 ` Jeff Wilson
@ 2000-08-04 4:00 ` hin-tak.leung@bt.com
2000-08-04 4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
2000-08-17 4:33 ` Josef Faulkner
3 siblings, 1 reply; 13+ messages in thread
From: hin-tak.leung@bt.com @ 2000-08-04 4:00 UTC (permalink / raw)
well, I am sure you can do:
find . -type f -exec rm {} \;
instead. This just delete the files one at a time in the current directory.
Probably isn't as efficient as "rm *", but it get around the problem of
arg list too long.
In article <8mbaa1$b09$1@nnrp1.deja.com>,
andrew.rycroft@intrinsitech.com writes:
>Hi,
>
>I am trying to delete files (with rm * ) from a directory which
>contains many files. I get the following error messages :-
>
>ksh: /sbin/rm: arglist too long
>
>Is there any other way of doing this other than writing a script to
>delete the files a*, b*, c* etc. ?
>
>What is the maximum no. of files I can delete ?
>
>I also hit a similar limitation with tar !
>
>Appreciate any input.
>
>Thanks
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-04 4:00 ` hin-tak.leung@bt.com
@ 2000-08-04 4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
2000-08-06 4:00 ` Timo Felbinger
0 siblings, 1 reply; 13+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 2000-08-04 4:00 UTC (permalink / raw)
In article <8me4hu$8i3$1@pheidippides.axion.bt.co.uk>, Hin-Tak@pc7221.btlabs.bt.co.uk (hin-tak.leung@bt.com) writes:
>well, I am sure you can do:
>
> find . -type f -exec rm {} \;
>
This is likely to take much longer than:
find . -type f -print | xargs rm
because, the first one will have to start a new rm for each
file. The 2nd one will use one rm for a whole bunch of
files. While UNIX forks are relatively cheap, they do take
time, I/O and page faults.
In the end, it will still be I/O bound though.
>
--
Alan Rollow alan@nabeth.cxo.dec.com
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-04 4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
@ 2000-08-06 4:00 ` Timo Felbinger
2000-08-06 4:00 ` John F Carr
0 siblings, 1 reply; 13+ messages in thread
From: Timo Felbinger @ 2000-08-06 4:00 UTC (permalink / raw)
On 4 Aug 2000, Alan Rollow - Dr. File System's Home for Wayward Inodes. wrote:
>
> In article <8me4hu$8i3$1@pheidippides.axion.bt.co.uk>, Hin-Tak@pc7221.btlabs.bt.co.uk (hin-tak.leung@bt.com) writes:
>
> >well, I am sure you can do:
> >
> > find . -type f -exec rm {} \;
> >
>
> This is likely to take much longer than:
>
> find . -type f -print | xargs rm
And in what sense is this better than a simple rm * ? Stuffing
all args into a single call to rm will hit exactly the same O/S
limits the original poster wanted to avoid.
In additon, your suggestion (as most applications of xargs)
is dangerous as it will fail for filenames containing spaces.
Timo Felbinger
--
Timo Felbinger <Timo.Felbinger@quantum.physik.uni-potsdam.de>
Quantum Physics Group http://www.quantum.physik.uni-potsdam.de
Institut fuer Physik Tel: +49 331 977 1793 Fax: -1767
Universitaet Potsdam, Germany
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-06 4:00 ` Timo Felbinger
@ 2000-08-06 4:00 ` John F Carr
2000-08-07 4:00 ` Timo Felbinger
0 siblings, 1 reply; 13+ messages in thread
From: John F Carr @ 2000-08-06 4:00 UTC (permalink / raw)
In article <Pine.LNX.4.21.0008061721000.30968-100000@uranos.quantum.physik.uni-potsdam.de>,
Timo Felbinger <Timo.Felbinger@quantum.physik.uni-potsdam.de> wrote:
>>
>> This is likely to take much longer than:
>>
>> find . -type f -print | xargs rm
>
>And in what sense is this better than a simple rm * ? Stuffing
>all args into a single call to rm will hit exactly the same O/S
>limits the original poster wanted to avoid.
xargs knows the maximum argument list size, and will run its command
several times if it is necessary to split the input list.
--
John Carr (jfc@mit.edu)
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-06 4:00 ` John F Carr
@ 2000-08-07 4:00 ` Timo Felbinger
0 siblings, 0 replies; 13+ messages in thread
From: Timo Felbinger @ 2000-08-07 4:00 UTC (permalink / raw)
On 6 Aug 2000, John F Carr wrote:
> xargs knows the maximum argument list size, and will run its command
> several times if it is necessary to split the input list.
>
Interesting; the man page seems to imply that I would need
the -s switch to get this behaviour. Then how do I have to
call xargs if I need all args in a single invocation of a
command, and I want an error rather than several invocations
if it is not possible?
(and I can't use -x and -s with an explicit length because I
don't know what the limit is)
Timo Felbinger
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting many files with rm
2000-08-03 4:00 Deleting many files with rm andrew.rycroft
` (2 preceding siblings ...)
2000-08-04 4:00 ` hin-tak.leung@bt.com
@ 2000-08-17 4:33 ` Josef Faulkner
2000-08-18 0:45 ` Richard M. Alderson III
3 siblings, 1 reply; 13+ messages in thread
From: Josef Faulkner @ 2000-08-17 4:33 UTC (permalink / raw)
ls -1 | awk '{ print "rm "$0 }' | sh
You can even test your intentions by replacing "sh" with "more"
--
Josef Faulkner
panther@gate.net
<andrew.rycroft@intrinsitech.com> wrote in message
news:8mbaa1$b09$1@nnrp1.deja.com...
> Hi,
>
> I am trying to delete files (with rm * ) from a directory which
> contains many files. I get the following error messages :-
>
> ksh: /sbin/rm: arglist too long
>
> Is there any other way of doing this other than writing a script to
> delete the files a*, b*, c* etc. ?
>
> What is the maximum no. of files I can delete ?
>
> I also hit a similar limitation with tar !
>
> Appreciate any input.
>
> Thanks
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: Deleting many files with rm
2000-08-17 4:33 ` Josef Faulkner
@ 2000-08-18 0:45 ` Richard M. Alderson III
2000-08-18 4:00 ` Tony Verhulst
0 siblings, 1 reply; 13+ messages in thread
From: Richard M. Alderson III @ 2000-08-18 0:45 UTC (permalink / raw)
In article <spmqoh61r5j105@news.supernews.com> "Josef Faulkner"
<panther@gate.net> writes:
> ls -1 | awk '{ print "rm "$0 }' | sh
This runs into the same objection as the _find_ solution, to wit, a separate
invocation of _rm_ for each file. _xargs_ is the correct solution.
Rich Alderson Last LOTS Tops-20 Systems Programmer, 1984-1991
Current maintainer, MIT TECO EMACS (v. 170)
last name @ XKL dot COM Chief systems administrator, XKL LLC, 1998-now
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2000-08-18 4:00 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-08-03 4:00 Deleting many files with rm andrew.rycroft
2000-08-03 4:00 ` Eckhardt Wallmeroth
2000-08-03 4:00 ` Tony Verhulst
2000-08-04 4:00 ` David Schmitt
2000-08-03 4:00 ` Jeff Wilson
2000-08-04 4:00 ` hin-tak.leung@bt.com
2000-08-04 4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
2000-08-06 4:00 ` Timo Felbinger
2000-08-06 4:00 ` John F Carr
2000-08-07 4:00 ` Timo Felbinger
2000-08-17 4:33 ` Josef Faulkner
2000-08-18 0:45 ` Richard M. Alderson III
2000-08-18 4:00 ` Tony Verhulst
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox