Bash one liner to clean out junk files from NAS

1

1

I bought a 2-bay QNAP NAS that I'll put 2 x 2TB hard drives in today and load up with my files. I'll be accessing the NAS via Xubuntu/Debian and Mac machines.

I'd like someone to teach me a bash one-liner (or something similar) that will clear out some of the junk files that have accumulated over the years of multi-platform access.

These include things like:

  • .ini
  • thumbs.db
  • .AppleDouble
  • .DS_Store
  • :2e*

I don't want to delete crucial metadata files, but .ini for example, I don't view as crucial and the same goes for .DS_Store.

Additionally, are there any easy ways to be proactive in the fight against spreading these junk files around? On the Mac, I did:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

a while back which should take care of future .DS_Store network spam. I'm not completely OCD but I'd like to avoid useless files where possible.

boehj

Posted 2011-07-13T22:09:28.550

Reputation: 1 042

Answers

3

find path/to/nas \( -name '.ini' -o -name ':2e*' -o ... \) -exec rm -rf {} \;

Ignacio Vazquez-Abrams

Posted 2011-07-13T22:09:28.550

Reputation: 100 516

Thanks very much. I'm looking forward to doing some weeding! – boehj – 2011-07-14T00:00:46.413