delete all .log files but some have spaces
find . -name *.log | xargs rm
says no such file for some of them. how do i fix
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
4 replies
find . -name '*.log' -delete
Quote the pattern, or your shell expands it before find sees it. If you've got one .log in the current dir you're searching for that one exact name.
And if you do want xargs for something other than deleting, use find -print0 | xargs -0, then spaces and newlines in names are fine. Or find ... -exec cmd {} + which does the same batching with no pipe.
Run it with -print before -delete the first time. -delete does what it says and there's no bin.
ok worked ty