Argument list too long – Shell

Turns out there is a limit on the length of a bash command. To find out the maxlength on your system go to the console and:

$ getconf ARG_MAX
262144

The other day when I was trying to delete (rm -rf) a very large folder with lots & lots of files the bash returned the following error:

/bin/rm: cannot execute [Argument list too long]

It’s because the bash was trying to expand the entire command with a list of files (arguments) it has to delete before executing. That list of files was too long and exceeded ARG_MAX.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s