The reason analysis of "Arg list too long" in Linux execution command error __linux

Source: Internet
Author: User

Http://www.yunweipai.com/archives/558.html

The reason analysis of "Arg list too long" in Linux execution command error

Tuna Hand Scroll was published 3 years ago in operation and maintenance experience in 2012-09-15

Recently, a problem has been encountered with the SUSE Linux operating system: Perform RM * Delete all files in a folder containing tens of thousands of files times wrong "Arg list too Long", which eventually resulted in a deletion failure. Later looked at the data, after analysis found here are several technical points to note:

1. In the Linux operating system has limited the length of a single command line is 128KB, that is, 131072 bytes, while RM * This command in the deletion of all files, this * as a wildcard character will eventually be converted to the full path of the file, so that the bottom of the system will be RM * Converted to a command line exceeding 128KB in size, thus command execution failed;

2. Query the Linux operating system for a single command line length limit: The Linux operating system can perform getconf Arg_max, echo information is the limit of the number of bytes;

3. The Arg_max parameter is 1048320 bytes (1024KB) in Solaris, in Linux Chinese 131072 bytes (128KB);

4. The Arg_max parameter definition is in the kernel of the Linux/unix operating system.

Finally, the problem of RM * mentioned above can be solved by using the combination of pipe character and xargs to ensure that only one file is deleted per rm, so it is impossible to have a single command exceeding the length of 128KB characters:
# ls | Xargs RM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.