If you are getting an error message as “Argument list too long” while attempting to run a command at Linux shell “find” command will be your lifeguard.
This error message tells you, the directory you are trying to work contains a huge number of files. That’s why the shell can not handle this operation.
Solution is simple. Try taking to pieces your batch. For instance try running cp conf*.txt /tmp instead of using cp * /tmp
If you can’t group the files as above you may use find command with exec option.
emreyasar@testserver:~> cp /srv/www/htdocs/cacti/rra/* /tmp/
-bash: /bin/cp: Argument list too long
At this situation this command will do what you are trying to do:
emreyasar@testserver:~> find /srv/www/htdocs/cacti/rra -name “*” -exec cp {} /tmp \;
You will like using find command with exec option.
It may simplify your works so many times.