Solved

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

Posted on 2002-03-04
3
321 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

626 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