Why does command:
rm **/*.pyc
removes nothing?
What is the proper way to achieve expected behavior?
Why does command:
rm **/*.pyc
removes nothing?
What is the proper way to achieve expected behavior?
To make your command work, you need to enable globstar
first:
shopt -s globstar
When globstar mode is enabled, **/*.pyc
will expand to match files ending in .pyc
in the current directory and all subdirectories.
Alternatively you could just use find
:
find -name "*.pyc" -delete
This will search for anything ending in .pyc
in the current directory and all subdirectories, deleting whatever it finds. To restrict it to only match files, you can add the -type f
switch as well, although this may not be a problem (and wouldn't have been the case in your original command).
Or, if your version of find doesn't understand -delete
:
find -type f -name "*.pyc" -exec rm {} \;