terminal Icon Logo
me@grafxflow

Written by me@grafxflow

11 Nov, 2018

0

10,690

Delete files starting with ._ using the terminal

I have always had an issue when copying files from macOS to a windows formatted drive, that I would suddenly find loads of files with the same name but hidden starting with '._'.

So how can we remove all these files, well my first thought was to show all the hidden files on macOS using the terminal but guess what they still didn't show.

See how to show hidden files in macOS with terminal or quick keys.

What about opening the directory using an application which allows you to see all the hidden files like 'Atom' and delete them this way, well first if they are in subdirectories this could be time consuming plus another problem happens - macOS doesn't recognize they are in the trash so you still can't delete them!

As per usual with most of these issues it can be solved completely 100% in the terminal.

So here is how we can remove all those files starting with '._'?

The input below searches for files starting with '._' and then lists them all.

find . -type f -name "._*" -print

But the more important part is how to delete them... well that is simple enough.

find . -type f -name "._*" -delete

Plus if you want to list the files which have been deleted use this.

find . -type f -name "._*" -print -delete

I hope this solves the problem I had for ages but thank goodness I found this solution.

Add comment

Smart Search

133 Following
50 Followers

me@grafxflow

Hull, United Kingdom

I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!

Follow