At times, you might get into a situation where you can't copy, move, remove or even list a huge number of files in a directory. When you attempt it, an error will be thrown saying "Argument list too long". This actually indicates that the OS has exceeded its Argument list limit. To know the Argument list limitation of your OS, run the following command "getconf ARG_MAX". It will show you the maximum number of arguments that can be passed to mv, cp, rm or ls command.
# getconf ARG_MAX
131072
To get rid of this problem, you must split your mv or cp command using wildcards.
Like instead of using "cp /folder1/* /folder2/ ", we should use "cp /folder1/a* /folder2/; cp /folder1/b* /folder2/"
(or)
you can use 'for' loop construct as follows:
# for i in {a..z}; do cp /folder1/$i* /folder2/ ; done &
Please note in 'for' loop, for every cp command it executes, it creates a new process id.
# getconf ARG_MAX
131072
To get rid of this problem, you must split your mv or cp command using wildcards.
Like instead of using "cp /folder1/* /folder2/ ", we should use "cp /folder1/a* /folder2/; cp /folder1/b* /folder2/"
(or)
you can use 'for' loop construct as follows:
# for i in {a..z}; do cp /folder1/$i* /folder2/ ; done &
Please note in 'for' loop, for every cp command it executes, it creates a new process id.