Progrider

Programming discussion

Board index
Help · ✓ Resolved

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

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

Discussion resolved

This discussion is resolved. Its creator can reopen it to accept more replies.