Argument list too long 🐧 Linux

bash: /bin/rm: Argument list too long

A glob like * expanded to more file names than the kernel allows in one command (ARG_MAX), so the command never ran.

Seen on: Linux

Meaning

The shell expands * before running rm/cp/mv. With hundreds of thousands of files the expanded arguments exceed the limit. Use find or xargs, which process files in batches.

Common causes

  • Glob matching a huge number of files (sessions, cache, logs)
  • Very long variable expanded into arguments

⚡ Quick fix

  1. Use find -delete
  2. Pipe to xargs in batches
  3. Delete the whole directory if appropriate

Detailed fix by platform

Linux

  1. bash
    find /var/lib/php/sessions -type f -name 'sess_*' -delete
    find . -name '*.log' -print0 | xargs -0 rm -f

How to diagnose

  1. Count — find dir -type f | wc -l
  2. Limit — getconf ARG_MAX

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.