Software⏱️ 2 min read📅 2026-05-31

How to Fix: Argument list too long error for rm, cp, mv commands

Argument list too long error for rm, cp, mv commands in UNIX.

Quick Answer: The solution is to use wildcards with quotes or escape the space in the filename. For example: rm -f \"*.pdf\" or rm -f "*.pdf".

The 'Argument list too long' error occurs when the shell is unable to process a command with an excessively long argument list. This issue can be caused by specifying multiple files in a single command, such as `rm -f *.pdf`, which attempts to delete all files with the `.pdf` extension.

🚀 How to Resolve This Issue

Method 1: Using Wildcards with Quoting

  1. Step 1: Wrap each file name in double quotes, like this: `rm -f "*.pdf"`.

Method 2: Using the `find` Command

  1. Step 1: Use the `find` command to search for files with the `.pdf` extension and pipe the output to `rm`: `find . -type f -name '*.pdf' -delete`.

🎯 Final Words

To avoid this issue for the `mv` and `cp` commands as well, you can use similar workarounds. For example, to move multiple files at once using `mv`, you can use the following command: `find . -type f -name '*.pdf' -print0 | xargs -0 mv`. This will move all files with the `.pdf` extension to a new location.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions