Solved

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

Posted on 2009-07-06
6
510 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

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!

Question has a verified solution.

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

Suggested Solutions

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

739 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