0

I'm getting a list of folders with command

locate my_folder

How i can empty/delete all files from those folders?

0

If you want to remove everything inside the folders and the folders themselves, pipe this:

locate my_folder | xargs rm -rf

Warning: No confirmation prompt or progress indication; irreversible data loss

Explanation of xargs rm -rf


If you want to remove everything inside the folders but keep the folders themselves, pipe this:

locate my_folder | xargs -I{} find "{}" -mindepth 1 -delete

Warning: No confirmation prompt or progress indication; irreversible data loss

Explanation of xargs -I{} find "{}" -mindepth 1 -delete

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.