find (too many arguments)

Conor P. Cahill cpcahil at virtech.uucp
Thu Jan 11 22:30:45 AEST 1990


In article <388 at usdtsg.Dayton.NCR.COM>, musson at usdtsg.Dayton.NCR.COM (Scott Musson) writes:
> 
> when I do a 'find p* -mtime +1 -print'   in a directory with a large number of
> files starting with 'p', I get find: too many arguments.


The problem is not with find, but with the shell (and OS).  There is a 
maximum number of arguments and/or number of bytes in those arguments.  Usually
this number is on the order of 5120 bytes.

To get around your problem you could do the following: 

Create the following shell:

	pgm="$1"
	shift
	args=""
	while [ ! -z "x$1" ]
	do
		if [ "x$1" = "xendargs" ]; then
			shift;
			break;
		else
			args="$args $1"
			shift
		fi
	done

	$pgm $* $args
		
and call it manysh.


now you can do:

	ls | grep "^p" | xargs | manysh find -mtime +1 -print



-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list