[OS X TeX] grep

Luis Sequeira lfsequeira at gmail.com
Mon May 11 11:31:56 CEST 2009


> To Herb, and all the other great wizards,
>
> The search of TeXShop contains the grep option. Unfortunately, this is
> inaccessible to all but a few, who learn grep and can remember it.
>
> Question: would it be possible to make it available to us, average
> users? An English like scripting language, or a pull down type menu
> structure? There was a word processor a while ago that had that.
>
> Like:
>
> Search for Char: not \, Char: ]
>
> meaning any char but \, followed by ].
>
> GG

I am certainly not one of the great wizards :-)
but I believe that such an effort would be much harder than the effort  
required to look up a few basic rules for grep. I, for one, looked up  
how to do your example and it took me maybe one minute. Here is the  
required regular expression:

     [^,]\]

In doing so, I made use of a little free application named Bwana,  
which allows one to read man pages without using the Terminal. Just  
type man:egrep (or man:ls, or whatever) in Safari's url box, and there  
you have it.

The rules for regular expressions are not that hard. Most characters  
just match themselves. Special characters, like brackets, backslash,  
asterisk, can be "escaped" by preceding them with a backslash - hence  
the \] above matches a single closing bracket. A string of characters  
inside a pair of brackets matches any one of those characters - e.g.,  
[abc] matches any of the letters a, b or c - unless the first  
character inside is a caret - ^ - which means negation. Hence [^,]  
matches any character except the comma.

There is much more, of course, but I hope this gives people an idea  
that is not that hard.
I don't always remember how to do it (I didn't remember about the  
caret in the example above, for instance), but if necessary I look it  
up. It has helped me countless times.

Luis Sequeira





More information about the macostex-archives mailing list