rm & mv command failed due to too many files.

In our directory there are too many files, & if I try to execute mv *.gz or rm *.l command it fails, providing error string as - 'arg list too long'. This doesnt happen always, is there any way we know, limit on the rm & mv command so we can take care of this failure in future executions ?

look into 'man xargs'

Hey,

I have created 100 directories and deleted them using rm -r *.abc
It works.
I dont think there is some kind of limitations to remove directories.
TO REMOVE DIRECTORIES recursive "-r" is to be used when give rm command.

Otherwise please tell how many sub directories you have under the main directory, then i can simulate the situation and could give you some solutions.

Thanks.
Varun:b:

The problem is when the wildcard expands to a string which is larger than the buffer the kernel allocates for this. Like vgersh99 said, read man xargs or How long can the command line be?

hope below command will solve the problem. It will run slow though...
find . -type f -exec rm -f {} \;
replace rm -f with the command you want to run.

How to find ARG_MAX on the AIX ?

The page I linked above has a script which works on some platforms. I'd appreciate if you could report back here.

Hi Vgersh

I am getting following error -

AIX 3 00C185BF4C00
Arg_Max.sh[13]: cpp: not found

or gcc not found.

getconf ARG_MAX

If you don't have a C compiler installed, I don't know how you could find it out. Maybe there is some sort of interface on AIX for printing out kernel constants? Or maybe somebody in the AIX forum could run this for us? I posted a separate thread. There's probably no point in continuing in this thread on this particular topic.