When Linux tries to pass too many arguments to a system command (ls *; cp *; rm *; cat *; etc…), an "Argument list too long" error occurs. This article will provide four solutions, arranged in order of complexity from low to high.
Method #1: Manually divide command line parameters into smaller parts
Example 1mv [al]* ../directory2
mv [mz]* ../Directory2
This is the simplest of the four methods, but far from ideal. You must have a way to split the file evenly, and for a very large number of files, you need to enter the N-pass command.
Method #2: Use the find command
Example 2 Method 2 Use the find command to filter the file list and pass the required files to a series of commands.
The advantage is that the find command has a very powerful filtering function, and, perhaps most importantly, this method requires only one line of commands.
The only downside is that Method 2 needs to traverse the file, so it takes a lot of time.
Method #3: Create function
Example3
#!/bin/bash
# Set the folder to be deleted RM_DIR='/Data/files'
cd $RM_DIRfor I in `ls`dorm -f $Idone
Method #4: Recompile the Linux kernel
The last method requires 2 words : Be cautious, this method is very advanced, so it is best not to try linux users without experience. In addition, be fully tested in the system environment before permanent use.
Method 4 only needs to manually increase the number of pages in the kernel that are assigned to command line arguments. Open the include/linux/binfmts.h file and have the following lines near the beginning of the file:
/*
* MAX_ARG_PAGES defines the number of pages allocated for arguments
* a maximum env+arg of 128kB w/4KB pages!
*/
#define MAX_ARG_PAGES 32
In order to increase the memory of the allocation line command line parameters, you only need to assign a larger value to MAX_ARG_PAGES, save, recompile, install, restart, get
in my system I increased the value of MAX_ARG_PAGES to 64, which solved all the problems. After changing this value, I have not encountered any problems. This is understandable. When MAX_ARG_PAGES is changed to 64, the longest parameter line occupies only 256KB of system memory – it is nothing for the current hardware standard.
The advantages of Method 4 are obvious, now you just have to run the command as usual. The disadvantage is also obvious. If the memory allocated to the command line is larger than the available system memory, it may cause a DoS attack on the system itself, causing the system to crash. Especially for multi-user systems, even a small increase in memory allocation can have a big impact because each user is allocated extra memory. So be sure to test it thoroughly to determine if your system can use Method 4.
That day, my colleague showed me an operation step on my computer, using an env command, well, I adm
Preparation before erection: To set up a DNS server, you must install a software program that provi
1. Lock the redundant self-built account in the systemCheck method:Execute the command#cat /etc/pas
Think about it, what if you want to change the size of an image to a smaller size? Of course, I will
Making embedded Linux file system with busybox
Configuration parameters How to install two Linux systems
Shell script to view Linux memory usage
Linux directory structure detailed
Linux mount command system mount and image processing
The problem of creating DBCA error problem under Linux operating system
centOS automatically installs php
Access Control for Files under Linux
Linux modify system date and time
Linux system installation php extension cURL
How to automatically connect ADSL
Thoroughly remove the "undercover" Trojan killer
Vista current directory open admin rights command line
Instantly let you become a master Ctrl+Esc play the start menu
Hosting Network Settings in Win8 System
The correct way to run TurboC under Win8 system
WinXP's skill of encrypting and decrypting files through the command line
Microsoft will merge WP and Windows Store
Windows 8 notification area does not have Intel graphics icon