Argument list too long

Apparantly this stems from a limitation in the kernel regarding the size of command arguments. The Argument list is too long error message is typically shown if you try to run a command on a large filelist (for instance targeting files in a huge directory using wildcards), because the Linux kernel will split every target file found as separate arguments.

Say you have a directory containing three files; file1.txt, file2.txt, file3.txt. Running the command rm * in this directory will actually be interpreted as rm file1.txt file2.txt file3.txt by the kernel.

Two quick solutions comes to mind.

Using a for loop:

for f in /home/itdb/deleteme/*; do rm "$f"; done

Using the find command:

find /home/itdb/deleteme -name "*" -delete

For more information, check out this stackoverflow question:
https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands

Was this post helpful?
Yes
No
Powered by Pixelbart

Leave a Reply

Your email address will not be published. Required fields are marked *