简体   繁体   中英

OSX / Unix find command to find Dropbox' conflicted copies

I'm trying to use this command to find all of my conflicted copies, created by Dropbox:

find ~/Dropbox/ -path "*(*'s conflicted copy [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*" -print

It does not seem to work though, even when I am in the folder with contents that should be a match. eg:

prefs (George’s MacBook Pro's conflicted copy 2017-02-11).db
prefs (George’s MacBook Pro's conflicted copy 2016-08-03).db
prefs (George’s MacBook Pro's conflicted copy 2016-08-04).db

It works with the -name primary:

$ find ~/Dropbox/ -name "*(*'s conflicted copy [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*" | wc -l
      19

You can also pipe to grep for easier syntax:

$ find ~/Dropbox/ | grep -E "\(.*'s conflicted copy \d{4}-\d{2}-\d{2}" | wc -l
      19

The -path primary is only examining the path part -- not the file name. The 'conflicted' file name is a base name and not in the path leading to that name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM