Reputation: 691
find . -name "*.pyc" -print0| xargs -0 rm
i use this command delete python compiled file but if current directory didn't have any *.pyc file this cmd will not work print out the error with rm command need operator args
how to handle this work if current directory didn't have *.pyc file this situation?
Upvotes: 1
Views: 113
Reputation: 801
If you can assume GNU find, then you can use find . -name '*.pyc' -delete
.
Alternatively, find . -name '*.pyc' -exec rm -rf {} '+'
.
Upvotes: 0
Reputation: 97918
Using find -exec
:
find -name '*.pyc' -exec rm {} \;
or the discard output technique:
find . -name "*.pyc" -print0| xargs -0 -I{} rm {} &> /dev/null
Upvotes: 1