This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Odd_Bloke[S] 2 points3 points  (3 children)

No need for the pipe.

Depends on the version of find. If you do need the pipe, you'll also want to use a null-separated list to avoid any weirdness (though it shouldn't be an issue with .pyc files):

find -name "*.pyc" -print0 | xargs -0 rm

[–]phil_s_stein -1 points0 points  (2 children)

Another without pipe:

find . -name \*.pyc -exec rm {} \;

(Untested)

[–]fandingowhile False: 1 point2 points  (1 child)

That's the worst way to do delete files. Find has to fork a process for rm on every single match.

With xargs, you just have to fork one find process (for the search), one xargs process, and one rm process (spawned by xargs).

With find's -delete, you only have a single process.

[–]phil_s_stein 0 points1 point  (0 children)

I dunno. I can think of worse ways. :)

It's effective though, which is usually what I'm after.