Bash: /usr/bin/rm: Argument list too long – Solution

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 rm, cp, ls, 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.

Error

bash: /usr/bin/rm: Argument list too long


All regular system commands, such as rm, ls, mv, cpand are likewise subject to this limit.

What does “argument list too long” represent?

“argument list too long” Indicates when a user feeds too many arguments into a single command that hits ARG_MAX Limit ARG_MAX defines the maximum length of argument To executive Celebration,

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:

getconf ARG_MAX

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.

Solution

there are many Solution To it problem ,bash: /usr/bin/rm: argument list too long,

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 mkdir Permission.

mass delete files using find Permission:

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

Leave a Comment