What
Linux Error – Argument list too long
root@ip-10-74-4-101:/tmp/vfs_cache# rm -f /tmp/vfs_cache/tmp_*.jar
-su: /bin/rm: Argument list too long
Why
This error occurs when there is a large number of arguments passed to a command, usually, we come across this while deleting a large number of files in a folder. This is caused because the command cannot accept the arguments passed due to its kernel limits. There is a limit on the size of arguments passed to a command. and the environment variables are “ARG_MAX” or “_POSIX_ARG_MAX” which defines the argument list. The kernel limit defined in /usr/include/linux/limits.h.
root@ip-10-74-4-101:/tmp/vfs_cache# getconf ARG_MAX
2097152
How
To resolve this issue there are many alternate commands available, few are.
find . -type f -exec rm -fv {} \;
find . -depth ! -path . -exec rm -rf {} \;
find . -type f -delete
for i in *; do rm -f $i; done