Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-07-06
6
Medium Priority
?
523 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
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
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
Course of the Month9 days, 23 hours left to enroll

927 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