Solved

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

Posted on 2002-03-04
3
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

752 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