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

**Code:** `Argument list too long` · **Category:** Linux · **Seen on:** Linux

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

## 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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/linux/argument-list-too-long)
