How to use different versions of grep on same system?
Hi,
I have got two versions of grep on my system. grep 2.5.1 which is in /bin grep 2.5.4 which is in /usr/local/bin . I complied it from source code. Question 1 Now, 'yum info grep' still shows the older 2.5.1a version. How can I tell yum that a new version of grep in on board now? Question 2 How can I remove the old grep? I tried using 'yum remove grep' but then it showed a huge list that too will be removed with grep so I didn't pursue this way. What will be the proper way? Question 3 When I run grep as a root, it uses 2.5.4. Although /bin and /usr/local/bin both are in root's $PATH. But when I run grep as user, it uses 2.5.1. Here too /bin and /usr/local/bin both are in its $PATH. What is the reason of this different behaviour? How can I ensure that every user gets grep 2.5.4 without using its absolute path? Regards |
Hya!
Answer 1. use absolute path. Answer 2. may not be easy. Answer 3. The one found first will kick in. Check PATH variable and which one comes first. (/bin and /usr/local/bin) Happy Penguins! |
Thanks for the reply.
Quote:
Here is the $PATH of root Quote:
Quote:
Quote:
Code:
yum info /usr/local/bin/grep So what do you suggest now? |
change the $PATH variable and make /bin come before the /usr/local/bin
|
Q1: don't know
Q2: mv /bin/grep /bin/grep.old Q3; ln -s /usr/local/bin/grep /bin/grep (after you have done Q2 above. Make sure it is has permissions as the original grep had. (usually -rwxr-xr-x. 1 root root 89964 2009-02-25 11:04 /bin/grep) |
You've had some good answers for q2, q3.
Re q1; you can't; yum only recognises stuff installed via yum (actually rpm under the covers). See rpm -V |
Your user shell may have hashed the location of the old grep command and this could be why it doesn't find the new version.
'hash' is a bash builtin command. As the shell finds commands along the search path it remembers the found location in an internal hash table. The next time you enter a command the shell uses the value in its hash table instead of searching the path again. Code:
# To see your 'hash' table:- |
Quote:
1. Move the grep version located in /usr/local/bin somewhere else. 2. symlink from /usr/local/bin to the desired version. Quote:
|
Thanks to all you guys for replying to my queries so promptly.
Quote:
Quote:
Quote:
Now, it seems that is really not easy to remove grep. No big deal, I can live with that. But if somebody as any idea about it then please share. Quote:
Quote:
|
Quote:
Quote:
Quote:
The INSTALL help with source code says Code:
./configure; make ; make check ; make install Moreover, old version of grep was installed with yum, so I don't think a compilation can affect previous version in anyway. If you have any idea then please share? Quote:
Regards |
All times are GMT -5. The time now is 07:25 AM. |