Operating System - HP-UX
1838727 Members
7244 Online
110129 Solutions
New Discussion

Re: Maxlength limit of command+parameters

 
SOLVED
Go to solution
Srini Jay
Valued Contributor

Maxlength limit of command+parameters

I have a directory named "xyz" which has few sub directories and different applications & users write to those dirs. Sometimes the file/dir permissions gets changed.
By end of the day, I'll have to change permissions to 664 for all files under 'xyz'.

When I did a "chmod 664 `find xyz -type f`", it changed all the file permissions to my satisfaction.

When I did a `find xyz -type f|wc`, I got the following result:
4395 4395 124963

Isn't there a limit for length of the command line (in the forum i read it is 256 characters and someone else said it is 1024)!
Can anyone tell if the command I'm using will ever fail due to its length (today it is 12500 chars approx)?

I can use "find xyz -type f -exec chmod 664 {}\;", but that one is very slow as it invokes chmod for each and every file! Help please...
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Maxlength limit of command+parameters

Ever since the early days of UNIX the maximum size has at least been 5120. On 11.x the size is much, much larger and can essentially be ignored. The smaller limits you mention typically refer to the maximum line length that can be read by standard utilities and have nothing to do with environment. The command you are really looking for is xargs. The idea is that your find command or ls feed xargs and it then processes the files via chmod in groups of 50 or so. Man xargs for details.
If it ain't broke, I can fix that.
Srini Jay
Valued Contributor

Re: Maxlength limit of command+parameters

Thanks! That helps!!
Bill Hassell
Honored Contributor

Re: Maxlength limit of command+parameters

The maximum command line length has drastically increased to 2megs. The actual value can be determined with the getconf command as in:

getconf LINE_MAX

(see man getconf for details).

BUT: There will never be a long enough line when your argument list is unbounded. In other words, when you find a directory with 10,000 files in it and type something like:

echo *

then the line length will be exceeded. So it is better to assume that you will always exceed the command line maximum length at the start and you'll always be safe. That's why xargs was created...to take an unbounded list of things and buffer them up so the line length is never exceeded.


Bill Hassell, sysadmin
Srini Jay
Valued Contributor

Re: Maxlength limit of command+parameters

Thanks!
"getconf LINE_MAX" returned 2048. I'll make use of xargs as suggested.
Thanks again...
Srini Jay
Valued Contributor

Re: Maxlength limit of command+parameters

thanks