mardi 24 mars 2015

Makes it a difference whether I use a different -n flag value for xargs in combination with find command ?


Assume, someone searches for files that match some criteria using the find command and pipes the result into the rm command.



find / -type f -name "*.jpg" | xargs rm


First, I am not sure if the command above will get an error if the number of found files is very big, because I guess there is a limit to the number of arguments a command like rm can hold.


Than, I know that I can set how many files are passed as arguments at once to rm. Xargs with -n3 would, for instance, pass three arguments to rm execute the command and repeat it until all files have been passed as arguments.


Now does it make somehow a difference what value I take for the -n option of xargs ? Do these command lines differ in some aspect , like for instance the duration of execution:



find / -type f -name "*.jpg" | xargs rm

find / -type f -name "*.jpg" | xargs -n1 rm

find / -type f -name "*.jpg" | xargs -n2 rm

find / -type f -name "*.jpg" | xargs -n3 rm

.
.
.

find / -type f -name "*.jpg" | xargs -n999 rm


Aucun commentaire:

Enregistrer un commentaire