[comp.sys.att] Runaway newsfiles break ls

pjh@mccc.UUCP (Pete Holsberg) (03/01/89)

I have so many .ara????, .arb????, .ina????? and .inb??? in
/usr2/spool/news that any command that uses metacharacters returns with
the "too many arguments" message, and ls runs out of memory and dumps core!

How can I either process these or get rid of them?

Thanks,
Pete
-- 
Pete Holsberg                   UUCP: {...!rutgers!}princeton!mccc!pjh
Mercer College			CompuServe: 70240,334
1200 Old Trenton Road           GEnie: PJHOLSBERG
Trenton, NJ 08690               Voice: 1-609-586-4800

karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) (03/01/89)

pjh@mccc.UUCP (Pete Holsberg) writes:
   I have so many .ara????, .arb????, .ina????? and .inb??? in
   /usr2/spool/news that any command that uses metacharacters returns with
   the "too many arguments" message, and ls runs out of memory and dumps core!
   How can I either process these or get rid of them?

# for i in 0 1 2 3 4 5 6 7 8 9
> do
>   for j in ar in
>   do
>     for k in a b
>     do
>       rm .$j$k*$i
>     done
>   done
> done

That should give it to the shell in metachar-manageable pieces.  But
don't expect it to be fast.

If not, there's always "rm -fr ..."

--Karl

jr@amanue.UUCP (Jim Rosenberg) (03/04/89)

In article <629@mccc.UUCP> pjh@mccc.UUCP (Pete Holsberg) writes:
>I have so many .ara????, .arb????, .ina????? and .inb??? in
>/usr2/spool/news that any command that uses metacharacters returns with
>the "too many arguments" message, and ls runs out of memory and dumps core!
>
>How can I either process these or get rid of them?

In a word, xargs.  xargs is indispensable in getting around the 1001 ways the
limits on the size of an arg list can bite you.  Something like this:

cd /usr2/spool/news
ls | grep '^[.]ara' | xargs rm -f

Oops you said even ls gags.  Well in that case you can try

cd /usr2/spool/news
find . -print | grep '^[.]/[.]ara' | xargs rm -f

This is a real peeg to walk the whole tree just to get the current directory --
you could always bang out a quick C program to read . using Gwyn's dirent
library if you don't have one.

(BTW \. would work fine in place of [.] in the regular expressions, but I make
it a habit to escape metacharacters in regular expressions with brackets
because that works with parentheses too.  \( is not the same thing as [(]!!!)

The nifty thing about UNIX is that there are always so many ways to do
something when one doesn't work you can try another.
-- 
 Jim Rosenberg
     CIS: 71515,124                         decvax!idis! \
     WELL: jer                                   allegra! ---- pitt!amanue!jr
     BIX: jrosenberg                  uunet!cmcl2!cadre! /