Solved

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

Posted on 2002-03-04
3
309 Views
Last Modified: 2013-12-05
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
Comment
Question by:petro2
3 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 200 total points
ID: 6840345
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
 
LVL 9

Expert Comment

by:PeterMac
ID: 6841173
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
 
LVL 5

Expert Comment

by:Nisus091197
ID: 6841174
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now