Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove shadow files "._*" in all folders.

Posted on 2009-07-06
6
Medium Priority
?
519 Views
Last Modified: 2013-12-26
We have a Samba (OS X 10.5) file server with 1.5M files and over 6,000 folders. When it crahsed we used all means to copy the files to another OS X 10.5 server and in one of the copy process it created shadow "._*" files for all folders and files.

Is there a script to traverse all folders from ./data onwards to delete all these duplicate files? each file is about 4kb ? Thanks.

i.e. all subfolders and files have a shadow "._<foldername>" or "._<filename>" file.
SMB-hidden-files.JPG
0
Comment
Question by:artradis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24791206
try this but be careful when you run it

cd /path (put the paren dir name of data)
find ./data -name "shadow._*" -o -name  "._*"

it runs and show the names you want to delete then, run

find ./data -name "shadow._*" -o -name  "._*" | xargs rm -r

0
 
LVL 48

Expert Comment

by:Tintin
ID: 24791215
I would first do

find /data -type f -name "_*" -ls

to verify the correct files are listed and then do

find /data -type f -name "_*" | xargs rm -f
find /data -type d -name "_*" | xargs rmdir
0
 

Author Comment

by:artradis
ID: 24796706
Hi,

When I run - find /data -type f -name "_*" -ls , it works and list all the files and folders with "._*"

But when I run with -  find /data -type f -name "_*" | xargs rm -f   and   find /data -type d -name "_*" | xargs rmdir

Both run very briefly and then displays "xargs: unterminated quote" and stops.

Anyway to resolve this?

Thanks.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Accepted Solution

by:
omarfarid earned 750 total points
ID: 24796824
it should not show the folders since it is looking for files only, try

find /data -type f -a -name "_*"
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 750 total points
ID: 24797563
Ah, I forgot you are on a Mac and would have lots of filenames with spaces and other interesting characters.

Make it

find /data -type f -name "_*" -print0 | xargs -0 rm -f
0
 
LVL 48

Expert Comment

by:Tintin
ID: 24800674
Not sure why you accepted omarfarid's answer.

Note that

find /data -type f -a -name "_*"

is the same as

find /data -type f  -name "_*"
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question