[X-Unix] Can I find some help here?

Albert Lunde atlunde at panix.com
Tue Apr 5 21:47:19 PDT 2005


On Wed, Apr 06, 2005 at 05:19:53AM +0100, Stroller wrote:
> I'm obviously doing something really stupid here, and would appreciate 
> any pointers. I've been faffing about at this half the night - all I 
> want to do is find (programatically) some of Safari's files so I can 
> add 'em to a tarball & copy them to my other computer.
> 
> I obviously want to exclude the Caches files, but I also have a couple 
> of files on my Desktop I want to exclude. I thought I'd start on that, 
> as excluding the caches from the tarball will be the same principle, 
> but I'm getting extremely stuck:
> 
> Powerboko:~ stroller$ find ./ -iname *safari*
> .//Desktop/Clearlight.BU/Essentials/Mac Utilities/1.0SafariBeta2.dmg
> .//Desktop/Clearlight.BU/Essentials/Mac Utilities/Safari.dmg
> .//Library/Application Support/SyncService/Backup Data/Safari
> .//Library/Application Support/SyncService/LastSync Data/Safari
> .//Library/Caches/Safari
> .//Library/Preferences/com.apple.Safari.plist
> .//Library/Safari

When using wildcards (a.k.a. "file globbing") in find terms 
like -name you want to quote the pattern, like saying

find . -name '*.txt'

This is to prevent the shell from expanding the wildcards
too soon in a different context. (Or in the case of -regex
completely misinterpreting them)

(Using the results of a find, you need to be careful on Max OS
that you properly quote file names containing spaces and other
unusual characters.)

It might also be worth considering find piped into egrep
with and without -v, as you can use it to do regular expressions
on the file path to match and reject things. Sometimes
this is easier than following the quirks of find (which
vary a lot across Unix flavors, etc.)

find . -type f | egrep -i 'match' | egrep -v '(ignore|skip)'



More information about the X-Unix mailing list