Move/copy/delete/ all these … 📁

Dejanu Alex
2 min readJan 14, 2021

--

What happens when you find 10.000 results ? What you’re going to use exec or xargs ?

The answer is dead simple, always xargs . When using -exec you run a separate instance of the called program for each element of input and when xargs is being used you are bundling/collecting the input and execute the command as few times as possible which is usually just once.

Execution time

Side notes:

The xargs command in UNIX is mainly used when building an execution pipeline from STDIN. Tools like grepcan accept STDIN as a parameter, but using xargs allows tools like rm,echo,mkdir accept to accept STDIN as arguments.

find <> -exec <command> {} \; execute command; true if 0 status is returned. all of the following arguments to find are taken to be arguments to the command until an argument consisting of ;is encountered. The string {} is replaced by the current file name being processed everywhere it occurs in the arguments to the command.

--

--

Dejanu Alex
Dejanu Alex

Written by Dejanu Alex

Seasoned DevOps engineer — Jack of all trades master of None

No responses yet