Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!mvb.saic.com!ncr-sd!ncrlnk!ncrstp!npdiss1!mercer From: mercer@npdiss1.StPaul.NCR.COM (Dan Mercer) Newsgroups: comp.unix.misc Subject: Re: Arg list too long error? Here's a work-around. Keywords: find Message-ID: <728@npdiss1.StPaul.NCR.COM> Date: 21 Nov 90 23:50:10 GMT References: <1990Nov14.192707.1099@millipore.com> <1990Nov16.001140.11923@druid.uucp> Reply-To: mercer@npdiss1.StPaul.NCR.COM (Dan Mercer) Organization: StPaul Lines: 82 In article <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 :>has the feature of being able to execute a command on the files that it finds. :>So, by giving the command: :> :>find . -name "SRW*" -exec rm {} \; :> :>I was able to delete all the SRW files. :> [...] :>Hope this helps. Any better ways? Please E-Mail me. Any way to aviod :>recursion? Again, please let me know... : :ls | grep '^SRW' | while read X :do rm $i :done : :-- :D'Arcy J.M. Cain (darcy@druid) | :D'Arcy Cain Consulting | I support gun control. :West Hill, Ontario, Canada | Let's start with the government! :+ 416 281 6094 | As a side issue, get a load of this construct taken from a host management utility (that not surprisingly failed with an 'ls - arg list too long' message cd /etc;ls * | grep hosts >/dev/null 2>&1 if test $? -ne 0 then echo /etc/hosts not found exit 1 fi This atrocity (instead of 'if test -f /etc/hosts ...') snuck by because the QA guys started with a small set of environment variables whereas I came in su'ed to root and I use about 1k of env variables. I eventually fixed the problem but bypassed it by clearing out my environment space of all but essential variables. As another aside, take a look at this creation: grep -v parm_a filename |\ grep -v parm_b |\ grep -v parm_c |\ grep -v parm_d |\ grep -v parm_e |\ grep -v parm_f |\ grep -v parm_g |\ grep -v parm_h |\ grep -v parm_i |\ grep -v parm_j |\ grep -v parm_k |\ grep -v parm_l |\ grep -v parm_m |\ grep -v parm_n |\ grep -v parm_o |\ grep -v parm_p |\ grep -v parm_q |\ grep -v parm_r \ >/tmp/config$$ The intent was to remove a number of different parms from filename so they could later be readded. It blew up when it ran me out of processes (we later found out that an application's de-installation procedure munged our PROCS and NPROCS entries for the configuration - gee, thanks). I, of course, had quite a few things running, unlike the QA people who come in on a nice clean box. It makes you wonder what kind of numbskulls that put to work writing software - with all the tools available to do this job - awk, nawk, sed, ex, egrep - they chose the most inappropriate tool and beat the hell out of the box to get things done. I replaced it with egrep egrep -v 'parma_a|parm_b|...|parm_r' filename. -- Dan Mercer NCR Network Products Division - Network Integration Services Reply-To: mercer@npdiss1.StPaul.NCR.COM (Dan Mercer) "MAN - the only one word oxymoron in the English Language"