Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Find and remove Mac OS X dotfiles

Stanislav KhromovStanislav Khromov

There are two types of hidden “dotfiles” that OS X clutters USB drives with:

.DS_Store and ._filename (for example ._catfish.jpg)

To find all these files in a folder (In example: /home/yourfolder ), run this:

find /home/folder -name ._* -o -name .DS_Store

To delete them instead of just displaying them, use this command:

find /home/folder -name "._*" -o -name ".DS_Store" | sed 's/.*/"&"/' | xargs rm

Note: The sed command is used to enclose all input sent to rm with quotes, so it works with files containing spaces.

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 0
There are currently no comments.