Solved

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

Posted on 2009-07-06
6
491 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 40

Accepted Solution

by:
omarfarid earned 250 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 250 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now