BASH - Troubleshooting

Argument list too long

Example:

rm *.txt
bash: /usr/bin/rm: Argument list too long

Solution:

find . -name '.txt' -type f -delete

NOTE: Argument list too long indicates when a user feeds too many arguments into a single command which hits the ARG_MAX limit.

  • The ARG_MAX defines the maximum length of arguments to the exec function.
  • This limit for the length of a command is imposed by the operating system.
    • You can check the limit for maximum arguments on your Linux system using this command:
      getconf ARG_MAX
    • Which will return something like this:
      root@server1:~# getconf ARG_MAX
      2097152