misc/157491: update ls/rm/mv/cp tools to be able to handle large amount of files

Jason Hellenthal jhell at DataIX.net
Thu Jun 2 04:59:37 UTC 2011


On Wed, Jun 01, 2011 at 12:00:33PM +0000, Eitan Adler wrote:
> The following reply was made to PR misc/157491; it has been noted by GNATS.
> 
> From: Eitan Adler <lists at eitanadler.com>
> To: bug-followup at freebsd.org, vermaden at interia.pl
> Cc:  
> Subject: Re: misc/157491: update ls/rm/mv/cp tools to be able to handle large
>  amount of files
> Date: Wed, 1 Jun 2011 11:59:36 +0000
> 
>  The limit is not in these tools. It is a constant number, defined in
>  bytes, in the kernel. This is designed to keep the amount of memory
>  required to store these command line options bounded.
>  You could see the value with
>  $getconf ARG_MAX
>  262144
>  
>  I suggest you use find + xargs which automatically will figure out the
>  correct number of arguments and run the command for you.
>  

Even using your shell to do this will yield better results than trying
to pass every file as an argument. Knowledge of how the shell works in
this manner can be learned from the manual and through some scripting
guides out there on the net "somewhere".

While find is just as sufficient, here is another example that will use
just the tools you mentioned.

mkdir -p /usr/obj/tmp_m
for file in /var/db/portsnap/files/*; do
	cp -v $file /usr/obj/tmp_m
done


This is probably one of the most commonly used shell scripting examples.

Large things can be done here. Good Luck.

-- 

"Unity can only be manifested by the Binary. Unity itself and the idea of Unity are already two." -- Buddha

 Regards, (jhell)
 Jason Hellenthal

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 522 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20110602/7ae87c47/attachment.pgp


More information about the freebsd-bugs mailing list