 |
 |
Doing specific searches
|
 |
|
 |
|
Senior User
Join Date: Jul 2006
Status:
Offline
|
|
How do I search for a specific type of document containing a specific word within a particular directory and its subdirectories? For instance, I want to find .css documents with the word "window" in a directory called "Global", and its subdirectories.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Go to the directory called Global, hit Find, choose Kind: Cascading Style Sheets and Name: window. Or does that not work for some reason?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2006
Status:
Offline
|
|
Originally Posted by Chuckit
Go to the directory called Global, hit Find, choose Kind: Cascading Style Sheets and Name: window. Or does that not work for some reason?
No, that does not work. Should it not be Contents: window? Anyway, that did not work either. If I do the search as Kind: Others... Cascading Style Sheet file with Contents as window, it does not fetch anything. I know that word is in some of those files.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
cd ~/The/Path/To/Global
find . -name "*.css" -exec grep -q window {} ';' -print
If you want that explained let me know.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2006
Status:
Offline
|
|
Originally Posted by WJMoore
cd ~/The/Path/To/Global
find . -name "*.css" -exec grep -q window {} ';' -print
If you want that explained let me know.
I understand everything up to and including the word "window". Why the braces and the semicolon enclosed in single quotes? Why the "-print"? I do not want to print the list, I just want to see it on the screen and refer to it.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
The -exec argument executes the following arguments (up to the semicolon) as a command. The "{}" inserts the name of the current matched file, and the semicolon is in quotes because otherwise the shell would interpret it (and prematurely end the command!) instead of passing it literally to the find command. The -print means to print the results to the screen.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
What he said 
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2006
Status:
Offline
|
|
Thanks for the help, people.
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
So complicated.
Why not just open the Global window and type "window .css" into the Spotlight field?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
Depends on your point of view. I work with UNIX every day at work so using find is just automatic. Plus I don't trust Spotlight all the time because even if a file just contains text it must be of a known extension to get indexed. I learnt this the hard way when I was trying to find a CUE file that contained the name of a certain song. Spotlight never found it because it didn't index cue files. find however came to the rescue. BTW this is the case with CSS files, they aren't indexed by default:
Code:
wmoore$ mdls afile.css
afile.css -------------
kMDItemAttributeChangeDate = 2006-11-11 11:14:10 +1100
kMDItemContentCreationDate = 2006-11-10 00:00:42 +1100
kMDItemContentModificationDate = 2006-11-10 00:00:42 +1100
kMDItemContentType = "dyn.ah62d4rv4ge80g65x"
kMDItemContentTypeTree = ("public.data", "public.item")
kMDItemDisplayName = "afile.css"
kMDItemFSContentChangeDate = 2006-11-10 00:00:42 +1100
kMDItemFSCreationDate = 2006-11-10 00:00:42 +1100
kMDItemFSCreatorCode = 0
kMDItemFSFinderFlags = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSLabel = 0
kMDItemFSName = "afile.css"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 501
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 7
kMDItemFSTypeCode = 0
kMDItemID = 65300
kMDItemKind = "CSS style sheet"
kMDItemLastUsedDate = 2006-11-11 11:14:10 +1100
kMDItemUsedDates = (2006-11-10 00:00:42 +1100, 2006-11-11 11:00:00 +1100)
The same file renamed to .txt gives:
Code:
wmoore$ mdls afile.txt
afile.txt -------------
kMDItemAttributeChangeDate = 2006-11-11 11:17:12 +1100
kMDItemContentCreationDate = 2006-11-11 11:17:12 +1100
kMDItemContentModificationDate = 2006-11-11 11:17:12 +1100
kMDItemContentType = "public.plain-text"
kMDItemContentTypeTree = (
"public.plain-text",
"public.text",
"public.data",
"public.item",
"public.content"
)
kMDItemDisplayName = "afile.txt"
kMDItemFSContentChangeDate = 2006-11-11 11:17:12 +1100
kMDItemFSCreationDate = 2006-11-11 11:17:12 +1100
kMDItemFSCreatorCode = 0
kMDItemFSFinderFlags = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSLabel = 0
kMDItemFSName = "afile.txt"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 501
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 7
kMDItemFSTypeCode = 0
kMDItemID = 65765
kMDItemKind = "Plain text document"
kMDItemLastUsedDate = 2006-11-11 11:17:12 +1100
kMDItemUsedDates = (2006-11-11 11:17:12 +1100)
Note that it now has a known content type (kMDItemContentType). There is an easy solution to this. The Spotlight preferences should allow a type to added to an existing content importer. This can be done manually by editing the content importer but shouldn't be necessary.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|