2

I'm trying to find snippets of code in a bunch of velocity files using Spotlight (specifically pages that contain a <html> tag. Spotlight's missing pages that contain that tag that I know are there. Is there a way to escape characters in Spotlight? What are some good alternative search engines for Macs?

I saw this article - http://www.macworld.com/article/132788/2008/04/spotlight2.html - but it doesn't say anything about special characters, like periods or tags.

Kevin Burke
  • 945
  • 4
  • 13
  • 31

2 Answers2

1

From the UI

Use Raw Queries from the Finder advanced search (aka Spotlight window).

This was answered here: How to use wildcard characters in Spotlight search?

Jump to finder search in Finder using Command-F (or use the global shortcut Command-Option-Space). Then change the Kind to "Others > Raw Query".

kMDItemDisplayName==*Searchword*

From the Terminal

mdfind

mdfind "kMDItemDisplayName=='*Searchword*'c"
  • c at the end - case-insensitive

grep

grep -iR "Searchword.*Another" ./*
  • -i - case-insensitive

  • -R - recursive search all the directories underneath

  • ./* - start search at the current directory, and search all non-hidden files (for hidden ./.*)

find If you only want to search filenames

find . -iregex .*Searchword.*Another.*

ripgrep Third party tool you can install, usually faster than grep

rg -i "Searchword.*Another"
  • -i - case-insensitive
Polo
  • 41
1

If you don't mind using the terminal then you could perform a grep search

example:

grep --recursive "foo" ~/Desktop

This will provide you with a list of files containing the regex "foo".

This will only search in the Desktop folder and any subfolders. Additionally you can use the --line-number option to also get the number of the line which has been matched.

If you just want to find files by filename you could also use the "find" utility.

redxef
  • 211