DEV Community

Discussion on: Linux Tips And Tricks

Collapse
 
mohanarpit profile image
Arpit Mohan

One of the reasons that I like -exec is that it makes the find command complete in it's own right.

Also, using the syntax find -name "*.java" -exec grep Main {} \+ is equivalent to xargs in terms of performance. Also it's shorter to type as compared to find -name "*.java" -print0 | xargs -0 grep "Main"

Collapse
 
ferricoxide profile image
Thomas H Jones II

I'm an old guy. Even in the early 2000s (nearly 10 years into my career), using find with its -exec flag — rather than piping things through xargs — was a great way to bring a system to its knees. Between the slowness of storage and blowing out the process-table space on the much lower memory systems, at the time, you kind of habituated to shuddering at just the thought of someone using -exec. Painful memories die hard, even when you know the apparent cost barely registers, any more.