mprakash
9th July 2004, 14:14
Sorry this query is related to Unix

When I try to delete a big list of files from my directory am gettting the error

ksh: /usr/bin/mv: 0403-027 The parameter list is too long.


If I remove part by part I am able to do it

I am new to Unix. Can anyone help me is there any settings which limits the amount of data in the folder to do this action

I have this problem even while copying or moving the files from one folder to the other.

Your quick help is appriciated..as am presently trying get it done with various options..but no success

techfan
9th July 2004, 14:45
Try using the xargs command (look it up in your man-pages).

You could try something like:

Move all files from directory $1 to directory $2, and echo each move
command just before doing it:

ls $1 | xargs -i -t mv $1/{} $2/{}

The above command works on a hp-ux system.

davismit
9th July 2004, 15:16
you could always use a while loop

ls | while read t
do
rm $t
done

obviously make sure your in the right directory :(

Juergen
9th July 2004, 15:38
I remember some years ago whe had a similar problem with the unix system that we use at that time.

The problem was a kernel limit regarding the ARG_MAX constant.
The value of the constant ARG_MAX defines how long an argument list your kernel can take on the command line before it chokes

We increase this constant to a higher value and the problem was solved.

Rgds,
Juergen

mprakash
12th July 2004, 05:53
Thanks everybody..

Juergen can you specify where exactly I can assign value for these constants.

Juergen
12th July 2004, 09:17
Sorry, but I think there is no general solution. Tuning of kernel constants differs from unix to unix.

norwim
15th July 2004, 10:21
This is a typical problem that you will run in on any unix system, only the number of args that are valid may differ.
I shouldn't worry about increasing the number of args by tuning the kernel, as there really is no problem dealing with large amounts of files.
What will always help is (something similar was mentioned above, but this is even shorter):

for i in *pattern* <ENTER>
do<ENTER>
rm $i<ENTER> (or any other command like mv, compress or whatever)
...... [more commands if you like,
....... where $i is one item at a time of the group defined in *pattern*,
....... each command followed by <ENTER> ]
done<ENTER>
With this construction the number of arguments is not relevant.

hth

Norbert

Gert Verheyen
15th July 2004, 12:39
I would use the fine command, to limit the number of files in one go.

the systax is as this:

find . -name "a*" -exec rm {} \;

be carefull: all files starting with an a will be removed with this command.

if all names look the same, there are find parameters to remove based on the date too. see the man find for more info.

you can test it first with this:
find . -name "a*" -exec ll {} \;

the {} will be replaced with the found file of the find command each time.
the \; closes the find statement.