Hostxpeed
Login Get Started →
Troubleshooting

Fix "Argument List Too Long"

4 min read
28 views
Jun 12, 2026

Understanding the Error

Command line arguments exceeded system limit (usually 2MB).

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

Fix 1: Use find with xargs

Instead of:

rm *.log

Use:

find . -name "*.log" -print0 | xargs -0 rm

Fix 2: Use find with -delete

find . -name "*.log" -delete

Fix 3: Process in Batches

for file in *.log; do
    rm "$file"
done

Fix 4: Use printf with xargs

printf "%s\0" *.log | xargs -0 rm

Fix 5: For cp/mv with Many Files

find . -name "*.txt" -exec cp {} /destination/ \;

Fix 6: Increase ARG_MAX

Check current limit:

getconf ARG_MAX

Increase (advanced, rarely needed):

sudo sysctl -w kernel.argmax=4194304

Prevention

  • Organize files in subdirectories
  • Archive old files regularly
  • Use databases instead of millions of small files

Was this article helpful?