Solved

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

Posted on 2009-07-06
6
497 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
If, like me, you have a lot of Dell servers in the estate you manage this article should save you a little time. When attempting to login to iDrac on any server I would be presented with two errors. The first reads "Do you want to run this applicati…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

785 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