Arg list too long error? Here's a work-around.
Dan Mercer
mercer at npdiss1.StPaul.NCR.COM
Thu Nov 22 10:50:10 AEST 1990
In article <1990Nov16.001140.11923 at druid.uucp> darcy at druid.uucp (D'Arcy J.M. Cain) writes:
:In article <1990Nov14.192707.1099 at 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 at 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 at npdiss1.StPaul.NCR.COM (Dan Mercer)
"MAN - the only one word oxymoron in the English Language"
More information about the Comp.unix.misc
mailing list