Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ames!uhccux!munnari.oz.au!uniwa!DIALix!bernie From: bernie@DIALix.oz.au (Bernd Felsche) Newsgroups: comp.unix.misc Subject: Re: Arg list too long error? Here's a work-around. Summary: Use xargs Keywords: find, xargs Message-ID: <602@DIALix.oz.au> Date: 17 Nov 90 06:12:43 GMT References: <1990Nov14.192707.1099@millipore.com> <1990Nov16.001140.11923@druid.uucp> Organization: DIALix Services, Perth Western Australia Lines: 40 In <1990Nov16.001140.11923@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes: >In article <1990Nov14.192707.1099@millipore.com> Jeff Lampert writes: >> [...] >>The 'find' command does'nt seem to have the 'Arg list' limitation. It also 'find' does have it, if you pass it too many arguments! The command used below hides filename expansion from the shell. Ask what would happen if you hadn't quoted "SRW*"? >>find . -name "SRW*" -exec rm {} \; >> [...] Unfortunate side-effect is that files with matching names in subdirectories will also be removed. The following method is slow and also requires many forks, making you very popular on a busy system. >ls | grep '^SRW' | while read X >do rm $i >done We all know that the "best" way is to allow the shell to expand filenames and echo them into xargs... right? vis: echo SRW* | xargs -n10 -n option defines the maximum number of arguments to pass to rm. This may be too many for some older systems, or where pathnames are very long... the -s option to xargs defines the size allowed, but then, most users don't know what size to use... I also thought that the 'xargs' debate had finished... but then, maybe nobody read the second-last entry in the reference manual. -- ________Bernd_Felsche__________bernie@DIALix.oz.au_____________ [ Phone: +61 9 419 2297 19 Coleman Road ] [ TZ: UTC-8 Calista, Western Australia 6167 ]