Argument list too long
Posted by Planet Malaysia on December 2, 2008
Have you seen error message: “Argument list too long” on Linux or Unix console before?
Basically this is a shell command line length limitations. The error “Argument list too long error message” occurs which anytime a user feeds too many arguments to a single command. Each command under Linux/UNIX accepts a parameter commonly known as command arguments. Normally it apply to Linux or Unix system commands such as ls *, cp *, rm *, mv * and etc.
Find out current command line length limitations:
# getconf ARG_MAX
Result:
131072
To get a better result, you may type command
# echo $(( $(getconf ARG_MAX) – $(env | wc -c) ))
Result:
129006
Man HELP:
getconf – print system configuration variables
wc – print the number of newlines, words, and bytes in files
-c, –bytes print the byte counts
For an example, I have more than 15000 files name filesync.blah.blah in my /tmp folder. Whenever I type ls /tmp/filesync*, I will get an error message “Argument list too long” as attached image below:

How to overcome the error message? Use find or xargs command.
The solution are:
# echo /that/directory/*|xargs ls
# find /that/directory|xargs ls
This is NOT work in my case.
# find /tmp/file* -exec ls {} \;
Possibly Related Posts:
- Google Public DNS Down?
- lppasswd: Unable to open passwd file: Permission denied
- Missing /var/log/lastlog
- Telnet service_limit error
- Google accounts on Twitter
Comments
One Response to “Argument list too long”
Leave a Reply
maybe u can also work with a for … but it is more complex:
for files in * ; do ls $files ; done
you can replace * to a path for example:
for files in /misc ; do ls $files ; done