sfbayman
sfbayman

Reputation: 1097

how to delete a file recursively from folders on mac / unix

I want to delete ._DS_Store file from the parent folder and all sub folders. How to delete the .DS_Store file recursively from all folders with single command? (using rm -rf command)

Upvotes: 13

Views: 15548

Answers (2)

lacostenycoder
lacostenycoder

Reputation: 11186

To do this in the current directory you can do

find $(pwd) -name .DS_Store -delete

or other commands in place of -delete as show in previous answer.

Upvotes: 2

Eric Renouf
Eric Renouf

Reputation: 14490

find parent_dir -name .DS_Store -delete

With GNU find at least. Otherwise

find parent_dir -name .DS_Store -print0 | xargs -0 rm -f

Or

find parent_dir -name .DS_Store -exec rm -f +

Upvotes: 28

Related Questions