Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
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…

948 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

20 Experts available now in Live!

Get 1:1 Help Now