Walker News

How To Fix Linux Argument List Too Long Error Of ls Or mv Command?

When using ls command to list some of the files in a folder, the command fails and returns “/bin/ls: Argument list too long”. However, this particular error only triggered when using wildcard character (e.g. asterisk or “*”).

Besides, the mv, cp, or rm command also returns “argument list too long” if wildcard characters used to select only particular group of files:

The trick to fix Linux argument list too long error.
What causes “argument list too long”?

This error is caused by fixed memory size allocated by kernel for command-line arguments. Advanced user can override this limit by increasing MAX_ARG_PAGES defined in binfmts.h header file and then recompile the Linux kernel.

For most general users and system administrators, you can apply some other different ways or workarounds to fix the “argument list too long” error that only happen once in a blue moon. Otherwise, the sysadmin is to be blamed :).

Actually, the find command in above screenshot should be working IF the “-name” syntax is corrected and also add in “-exec” option to apply action command (ls, mv, cp, rm, etc).

For example, to list file:
find . -name "*.dat" -exec ls -l {} \;

To move file (replace mv to cp or rm for copy or delete):
find . -name "*.dat" -exec mv {} /tmp \;

So, if you happen to encounter this particular error, don’t feel worry and panic, as you can get rid of it in no time!

Custom Search

2016  •  Privacy Policy