Need grep package with -A option for Solaris 10
Need grep package with -A option for Solaris 10
-------------------------------------------------------------------------------- Hi Guys, I need grep package with -A option for Solaris 10, Where can I download this from, Please advise. |
GNU Grep for Solaris is available here: Sunfreeware
|
yes,i have downloaded from it. but it has no A option.
please suggest. |
try full path
/usr/gnu/bin/grep |
Are you using the full path to gnu grep? Its been a while, but I do believe gnu grep is installed in /usr/local/bin.
|
look i wan to try this
http://stackoverflow.com/questions/1...-matching-line I should be abale to print line above and below of searched word say "failed" now tell me how to do the same thing in Solaris 10 Code:
[raju@100 ~]$ grep -A 1 -B 1 oprofile /etc/passwd |
Quote:
Please answer the question asked by Firerat and me. It would also be nice if you posted the command you are trying to use. Quote:
|
I dont mean rude . please!
|
I want to do the same thing as posted above to search some logfile and their above below lines around particular search word in Solaris 10
|
see posts #4 and #5
I've never used solaris , so I don't know which is 'true' only going off what I have seen posted here on LQ in the past |
Code:
-bash-3.2$ which grep I have this grep located at system. |
To make sure you are using the GNU version:
Code:
/usr/local/bin/grep --version Code:
/usr/local/bin/grep -A ....... |
Code:
-bash-3.2$ /usr/local/bin/grep --version |
Code:
-bash-3.2$ /usr/local/bin/grep -A 1 -B 1 ongert /etc/passwd I hope it is solved now. |
Glad to see you got this fixed.
You can use -C instead of both -A and -B: Code:
/usr/local/bin/grep -C 1 ongert /etc/passwd |
A little late but as this is Solaris 10, GNU grep was probably already installed in /usr/sfw/bin/ggrep (not a typo the first g is for GNU).
|
Thanks guys.
But one quetion , this is simple but I really never did this to be honest What can I do to avoid using the full path Code:
/usr/local/bin/grep Code:
grep -C 2 user1 /etc/passwd Code:
/usr/local/bin/grep -C 2 user1 /etc/passwd and yes thanks for that "-C" option, its good one. |
you could put /usr/local/bin/ at the beginning of PATH
Warning: might break other things.. better solution .. try ggrep , if nothing then create a symlink in /usr/local/bin/ Code:
ln -s grep /usr/local/bin/ggrep you just have to remember to use ggrep never used solaris, but I assume you can use alias Code:
alias grep="/usr/local/bin/grep" alias ggrep=..... |
@manalisharmabe: I would first check if jlliagre solution works for you.
Assuming that ggrep isn't working for you: If you want/need to use GNU grep inside scripts I would set a variable at the beginning of that script that points to it. From that point on you can use the variable instead of the full path: Code:
#!/bin/bash |
Quote:
|
Quote:
Thanks Guys. |
Quote:
if it is for interactive use, then the ggrep symlink is probably best ( if ggrep doesn't already work, as pointed out by druuna ) |
It it isn't already, you can just put /usr/sfw/bin at the END of your PATH and if installed, ggrep will work as is.
|
yes as jlliagre points out, look for /usr/sfw/bin
really you need to figure out what you have installed on your system(s) |
All times are GMT -5. The time now is 05:49 PM. |