Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating grep for Mac OS 10.7

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? I could use Fink or MacPorts to install a new version and set my path variable to look in the appropriate branch of the file tree, or I could update the grep program in usr/bin, or perhaps there's another approach that I haven't considered. Because I am relatively new to the command line and the Unix back-end of the Mac, I'm concerned about breaking something. That said, I'd certainly be willing to compile the most recent stable release of grep from source and install it in /usr/bin if that's the appropriate method. In case anyone wonders why I'd want to update grep from 2.5.1, I have two reasons: 1st, I'm learning to use grep with a reference book that is based on 2.5.3 (probably similar, I know); 2nd and more importantly, I want to learn how to update such programs simply as a matter of administrating my own system effectively.

like image 303
Gregory Avatar asked Dec 04 '22 06:12

Gregory


1 Answers

As you said, you may use Fink, MacPorts, etc...

But if you just want to update grep, you may want to grab the sources, and compile them.

If you decide to go with this option, don't install it in /usr/bin.

If you do so, you will overwrite something needed by your OS.
So with another version, you may encounter problems, as the OS will except another version.

And also, if you do so, you'll have problems when updating your OS, as it might overwrite your own version.

So if you want to compile it, place it in /usr/local/bin (usually with the --prefix option), and update your path environment variable.
This is the safe way.

Usually, compiling such a program is just the standard ./configure, make and sudo make install stuff.
But be sure to take a look at the compiling options first, by typing:

./configure --help
like image 127
Macmade Avatar answered Dec 14 '22 02:12

Macmade