Trying to remove certain folders from my directory tree.
rm -r `find -name .sbas`
For some folders it fails like this:
rm: cannot remove ‘./Reports/Report’: No such file or directory
rm: cannot remove ‘11/.sbas’: No such file or directory
The whitespace in the folder path is confusing the command into thinking it's getting two different paths.
What's the best way to handle this? Removing the whitespace from the folder names is not an option.
Don't use output of find in rm like that.
Use find -delete:
find . -name .sbas -delete
Or on systems where find doesn't support delete use:
find . -name .sbas -exec rm -r '{}' \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With