Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

Can't delete a large number of files at one time

When I type rm -r * I get
                                 
-ksh: /bin/rm: cannot execute [Arg list too long]  

How can I do this in one step what do I need to change. Unixware 7.0 newuser.

0
petro2
Asked:
petro2
1 Solution
 
yuzhCommented:
Hi petro2,

   I saw this problem with SCO 3.2.2 long time ago. since you are using ksh, you can try to use the following command:

  # for i in * ; do
  # rm -r $i
  # done

  or use find command to delete the files:

  cd /targetdir
  find . -print -exec rm -r {} \;

  The above find command should works for you.

=======
yuzh
0
 
PeterMacCommented:
petro2

First suggestions from yuzh are good workaround for this problem. I just wanted to pass on some extra info for you.

Problem is general to all versions of unix, not just SCO. It is caused by finite length of command buffer. When * is used Unix expands this on the command line buffer, if this causes command buffer to overflow then you get the error you had. Unfortuneately, unlike DOS there is no easy way to increase size of command buffer. You better get used to using the "for i in *" you will need it again !
0
 
Nisus091197Commented:
This will handle lots of parameters and it's fast too:

find . -type f | xargs rm

It should delete enough files so you can finish with the 'rm -r'

Regards, Nisus
http://www.omnimodo.com
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now