jbanana: Badly drawn banana (Default)
[personal profile] jbanana
In bash, I want to delete a lot of files. Easy enough:
rm somepath/prefix*.txt
But I get "Argument list too long" because there are a *lot* of files. Well, I know I can use find like this:
find somepath -name "prefix*.txt" -exec rm '{}' \;
but that removes the files one at a time, and there are thousands of them so it's inefficient (and I'm impatient).

Solution:
find somepath -name "prefix*.txt" -print0 | xargs -0 rm
Nice - the output from find is collected up by xargs until it has a nice big list but not too big and then it executes rm on that list, and repeats until none left.

Now I can't see what was baffling me.
(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

May 2025

M T W T F S S
   1234
5678 91011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 13th, 2025 01:02 pm
Powered by Dreamwidth Studios