When Linux deletes a large number of files, an argument list too long error is reported

When linux deletes a large number of files, an error is reported argument list too long 

Reason: The amount of deleted data is too large

Solution:

1. Delete all files in a folder:

cd to the folder to be deleted

#Delete all files  

ls | xargs rm -r   

After execution, some files may not be deleted, and then execute

find ./ * -exec rm -f {} \;

 

2. Find some files in the folder and delete:

cd to the folder to be deleted

#Find all files with the suffix .temp and delete

find ./ -name "*.temp" | xargs rm -rf "*.temp";

 

 

https://blog.csdn.net/kwame211/article/details/82019507

The mv Times parameter list is too long,

for i in *.m;do mv $i ${i%.m};done

So I turned to google, and the exploration process was omitted. Let's just talk about the solution:

ls dir1 | xargs -t -I {} mv {} dir2/{}

The pair of curly braces here are used in the example given in the original text. Later, I saw the usage of the parameters. In fact, the pair of curly braces can be replaced with any string, such as:

ls dir1 | xargs -t -I asdf mv asdf dir2/asdf

The effect is exactly the same as the version with braces, but it looks a bit unserious.

It should be noted that the second parameter of xargs above is the uppercase i, the letter pronounced "love", not the lowercase L. As for the meaning of the parameters, I forgot.

Guess you like

Origin blog.csdn.net/hzp666/article/details/113756612