LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Need grep package with -A option for Solaris 10 (http://www.linuxquestions.org/questions/solaris-opensolaris-20/need-grep-package-with-a-option-for-solaris-10-a-4175474131/)

manalisharmabe 08-21-2013 06:44 AM

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.

druuna 08-21-2013 06:51 AM

GNU Grep for Solaris is available here: Sunfreeware

manalisharmabe 08-21-2013 06:56 AM

yes,i have downloaded from it. but it has no A option.
please suggest.

Firerat 08-21-2013 07:03 AM

try full path

/usr/gnu/bin/grep

druuna 08-21-2013 07:03 AM

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.

manalisharmabe 08-21-2013 07:13 AM

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
sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
[raju@100 ~]$

above is what we do in linux, so how to do this in Solaris

druuna 08-21-2013 07:17 AM

Quote:

Originally Posted by manalisharmabe (Post 5013064)
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"

We know what the -A and -B switch do.

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:

now tell me how to do the same thing in Solaris 10
Play nice! We are trying to help but we cannot if you don't answer our questions!

manalisharmabe 08-21-2013 07:20 AM

I dont mean rude . please!

manalisharmabe 08-21-2013 07:21 AM

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

Firerat 08-21-2013 07:22 AM

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

manalisharmabe 08-21-2013 07:23 AM

Code:

-bash-3.2$ which grep
/usr/bin/grep
-bash-3.2$ cd /usr/local/bin
-bash-3.2$ ls grep
grep
-bash-3.2$

-
I have this grep located at system.

druuna 08-21-2013 07:25 AM

To make sure you are using the GNU version:
Code:

/usr/local/bin/grep --version
GNU grep <version number>

...
...

If the above is the case you can use:
Code:

/usr/local/bin/grep -A .......

manalisharmabe 08-21-2013 07:27 AM

Code:

-bash-3.2$ /usr/local/bin/grep --version
/usr/local/bin/grep (GNU grep) 2.14
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
-bash-3.2$

this what i have

manalisharmabe 08-21-2013 07:33 AM

Code:

-bash-3.2$ /usr/local/bin/grep -A 1 -B 1 ongert  /etc/passwd
rfasdbal:x:4841:102:ASD baleni (Liberec Information System User):/users/cz/182/rfasdbal:/usr/bin/ksh
ongert:x:4842:102:Onger Tomas (Liberec Technical User):/users/cz/182/ongert:/usr/bin/ksh
krizovd:x:4843:102:Krizova Denisa (Liberec Production User):/users/cz/182/krizovd:/usr/bin/ksh
-bash-3.2$

Thanks a LOt guys! Love you!

I hope it is solved now.

druuna 08-21-2013 07:38 AM

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
BTW: Can you put up the [SOLVED] tag (upper right corener or Thread Tools menu).


All times are GMT -5. The time now is 11:43 AM.