linux - Maximum number of Bash arguments != max num cp arguments? -


i have been copying , moving large number of files (~400,000). know there limitations on number of arguments can expanded on bash command line, have been using xargs limit numbers produced.

out of curiosity, wondered maximum number of arguments use was, , found this post saying system-dependant, , run command find out:

$ getconf arg_max 

to surprise, anwser got was:

2621440 

just on 2.6 million. said, number of files manipulating less -- around 400k. need use xargs method of moving , copying these files, because tried using normal mv * ... or cp * ... , got 'argument list long' error.

so, mv , cp commands have own fixed limit on number of arguments can use (i couldn't find in man pages), or missing something?

as ignacio said, arg_max maximum length of buffer of arguments passed exec(), not maximum number of files (this page has in-depth explanation). specifically, lists fs/exec.c checking following condition:

page_size*max_arg_pages-sizeof(void *) / sizeof(void *) 

and, seems, have additional limitations:

on 32-bit linux, argmax/4-1 (32767). becomes relevant if average length of arguments smaller 4. since linux 2.6.23, function tests if number exceeds max_arg_strings in <linux/binfmts.h> (2^32-1 = 4294967296-1). , additional limit, 1 argument must not longer max_arg_strlen (131072).


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -