Over time, the storage you use on the Linux system you manage will increase. As a result, you will, at some point, attempt to delete, move, find, or otherwise manipulate thousands of files using commands, such as
mv, and so on, all of which are subject to this limit. Thus, you will eventually come to this “argument list too long” The error details are given below.
bash: /usr/bin/rm: Argument list too long
All regular system commands, such as
cpand are likewise subject to this limit.
What does “argument list too long” represent?
An argument, also called a command-line argument, can be defined as the input given to a command, to help control the command line process. Arguments are entered in the terminal or console after the command is typed. Multiple arguments can be used simultaneously; They will be processed in the order typed from left to right.
This limit for command length is imposed by the operating system. You can check the maximum arguments limit on your Linux system using this command:
which would return something like this:
hydn@centos:~$ getconf ARG_MAX 2097152
“argument list too long” The error means that you have exceeded the maximum command-line length allowed for arguments in the command.
Delete the folder itself and then recreate it.
If you are trying to delete all files and folders in a directory, instead of using the wild card “*” to delete (ie
rm *), You can try the following:
rm -r /path/to/directory/
If you still need that directory, recreate it with
mass delete files using
You can use the find command to find each file and then delete them:
find . -type f -delete
Or to remove only specific file types (ie, .txt files) or otherwise, use something like this:
find . -name '.txt' -type f -delete