I would like to update grep on my Mac to a more recent version than 2.5.1, which came with Mac OS 10.7.2. My question is: what is the best way to update grep (or any similar program) for the Mac? If you are new to this blog; we use the Mac’s OS X kernel Terminal program to explore command line *nix functionality- So fire up your Terminal program!! Still looking at the – grep – man pages and discovered the ‘-m’ argument. 10 AppleScripts to make you love your Mac (even more) Apple's highly useful scripting language is one of the Mac's hidden gems. Windows Grep, Find & Replace with data extraction AJC Grep is a powerful file finder, text search, replace and data extraction program for Windows. This is a major time saving tool for developers, documenters, web designers and anyone who has to search.
- Mac Os Grep Examples
- Mac Program For Slideshow With Music
- Grep Options In Linux
- How To Grep On Windows
Active9 years, 9 months ago
This is a question coming from a former/current Windows user. If I'm looking at a Finder window in a particular directory, how can I search for files with names matching a particular pattern (e.g. 'p*.php') that contain a particular string of text?
Chealion
22.6k7 gold badges61 silver badges71 bronze badges
Jason SJason S
3,04311 gold badges53 silver badges74 bronze badges
![Color Color](/uploads/1/2/6/3/126353318/125210505.png)
Mac Os Grep Examples
5 Answers
You can't do this from the spotlight icon in the menu bar. But you can do it with spotlight:
-
Navigate to the folder in the finder.
-
Type your search of the content in the file you are searching for in the search bar on the top right of the folder.
-
There is a line above the results that says:
Search: This Mac 'Your Folder Name'
Click on the name of your folder to restrict the search to the folder instead of the whole computer, which is what the default selection 'This Mac' does. -
Then click the gear icon, choose show search criteria, and narrow down your search. For example you can add 'Name ends with .php' and then click the plus to add another criteria. You could then add 'Name begins with p'
Mac Program For Slideshow With Music
Edit: I just grabbed a php file and searched for this string
array_push($songs,$song)
and it will not find the file, but if I only search up to the comma (ie array_push($songs
) spotlight does find the file!
I found this article which explains how to add php as a supported file type for spotlight which should fix the weird result I experienced above. I believe without this change spotlight treats the file as rtf only so some php elements (punctuation especially) will make the search fail. The command to edit the required file is:
You'll want to reindex after this change as the article mentions. It also mentions the more proper way to do this is to install the developer tools.
You can then use the method I described above to restrict your search to a specific folder or file type.
ridogiridogi
2,6571 gold badge13 silver badges24 bronze badges
One simple way is Spotlight, in the upper right hand corner of the file window or the desktop screen; that's plain text for file names and strings. Grep is possible with Terminal and *unix commands (Terminal is in Applications/Utilities/). There's Aqua Command-Line Tools, though it looks old.
markratledgemarkratledge
Some programmer's text editors offer a grep-like feature for searching for a regular expression across multiple files; many (many) moons ago BBEdit had this feature (and probably still does; I just haven't used it for years). I wouldn't be surprised to find that other tools targeted at the developer market also have similar features.
Grep Options In Linux
larskslarsks
Both Spotlight and the Finder are an attempt at reaching out to the sort of people who keep the 'For Dummies' line of books on shelves, and as such, are not capable of parsing regular expressions or anything else particularly fancy. A lot of people like PathFinder as a replacement but I find it more trouble than it's worth since the Finder will keep launching itself no matter what you do.
Hasaan ChopHasaan Chop
4,1761 gold badge14 silver badges13 bronze badges
Using AppleScript (and
ChealionChealion
do shell script
to use Perl) it's possible to run a script to select all the files that match a regular expression. This can be combined with programs such as FastScripts and is actually documented and available for download by the developer on his blog.
22.6k7 gold badges61 silver badges71 bronze badges