Visit Our UNIX and Linux User Community

How to find egrep version on Solaris 10

Thread Tools Search this Thread
Operating Systems Solaris How to find egrep version on Solaris 10
# 1  
Old 01-04-2006
How to find egrep version on Solaris 10

How can I find the egrep version installed on Solaris 10 as I don't see any egrep --version option.Also wanted to know which version would support option of -A (eg. egrep -A NUM PATTERN FILE )
Print NUM lines of trailing context after matching lines.

Thanks & Regards,
# 2  
Old 01-04-2006
i can only help answer the first question ...

1. grep out /usr/bin/egrep from /var/sadm/install/contents

2. the package that installed egrep on my box is SUNWcsu --- verify on your box by looking at the last column on the output of grep

3. pkginfo -l SUNWcsu | grep "VERS"
# 3  
Old 01-04-2006
Hi ,
Just Ice,Thanks for your reply.I found my egrep version to be VERSION:11.10.0 on my Solaris 10 Box.But would anyone help me if I can have -A option with egrep coz this option is supported on linux egrep (GNU grep) version 2.5.1 or is there any other option on Solaris that would give me similar results.

Thanks & Regards,
# 4  
Old 01-05-2006
-bash-3.00$ ./ ab 0 0 ./testfile
-bash-3.00$ ./ ab 0 2 ./testfile
-bash-3.00$ cat ./
# no -C option to grep? no fear...
# usage:
#   scriptname "searchterm" lines_before lines_after inputfile


matches=`echo "${line}" | egrep -n "${matchstring}" ${matchfile}`
if [ "$?" -ne "0" ]; then
   echo "No match" >&2
   exit 1
echo "${matches} " | while read line; do
   lineno=`echo "${line}" | cut -d: -f1`
   match=`echo "${line}" | cut -d: -f2`
#  echo "Match found - line ${lineno} - ${match}"
   minline=$(( lineno - ${lines_before} ))
   [[ "$(( lineno - ${lines_before} ))" -lt 1 ]] && minline=1
   [[ "${lines_before}" -gt "0" ]] && \
   sed -n "$minline,$(( lineno - 1 ))p" ${matchfile}
   sed -n "$lineno p" ${matchfile}
   [[ "${lines_after}" -gt "0" ]] && \
   sed -n "$(( lineno + 1 )),$(( lineno + ${lines_after} ))p" ${matchfile}

exit 0

So for your requirements

scriptname "searchterm" 0 <trailing_lines> filename

# 5  
Old 01-05-2006

I think this question came in a recent post .... You can try out some solutions given in that post :

Sabari Nath S
# 6  
Old 01-06-2006
Hi Zazzybob,
Thanks for script Smilie Its cool!!!
But would still like to know if Solaris does NOT support this option for egrep as in linux.

# 7  
Old 01-07-2006
Solaris 10 and below do not support it - load GNU grep on your system instead.
Where to get egrep

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Egrep find word that occurs twice in a row

Hi there I am trying to figure out and understand what the syntax would be to egrep lines that have a word occur twice in a row. the two words obviously should have a space between them and also it has to be case sensitive which I believe grep is by deffault. the closest I have come is... grep... (7 Replies)
Discussion started by: spo_2138
7 Replies

2. Shell Programming and Scripting

Egrep on Solaris

how can I implement egrep -A 1 "(HI|FR|GO|TAT)" in solaris? (5 Replies)
Discussion started by: aydj
5 Replies

3. Solaris

How to read this Solaris version:-Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC?

Hi Guys, Could you please tell me how to read this Solaris version:- Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC Thanks. (3 Replies)
Discussion started by: manalisharmabe
3 Replies

4. Shell Programming and Scripting

Egrep ERE to find null

Hello All, My apologies if a similar question has already been posted. I searched for "grep", "egrep" and "null" I'm having an issue with egrep and an extended regular expression. I'm doing a test for a job name. I would like to have the user enter a job name with no spaces and also test to... (7 Replies)
Discussion started by: sydox
7 Replies

5. Shell Programming and Scripting

egrep help required to find pattern

Hi All, Can some one please help me how to grep the comments from "oracle" & "sybase" code. I would like to grep below type of pattern. -- /* */ Please help. (6 Replies)
Discussion started by: gr8_usk
6 Replies

6. Solaris

what is the command to see the java version in solaris 8 and solaris 10

what is the command to see the java version in solaris 8 and solaris 10 (1 Reply)
Discussion started by: tv.praveenkumar
1 Replies

7. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

8. UNIX for Dummies Questions & Answers

Find Software Version

Hi, Is there anyway to find what version of a software is installed on a particular box ? For Tru64 unix, the setld -i command lists all the software that is installed. But how do i get the version ? is there a unix command for this? Is setld specific to Tru64 ? Do reply VJ (1 Reply)
Discussion started by: vjsony
1 Replies

9. UNIX for Dummies Questions & Answers

How do I find out what version of X I'm using?

How can I find out? Besides looking on the box of my distro and checking their. (2 Replies)
Discussion started by: DISTURBED
2 Replies

10. UNIX for Dummies Questions & Answers

How do I find Unix Version

I am extremely new here. Someone wants to upgrade off of Unix to Windows 2000 and wants to know if they need to buy new hardware How do I find out what type of Unix they're using? How do I find out the current hardware of the system? (Intel, ..etc) Thanks (3 Replies)
Discussion started by: tomsha
3 Replies

Featured Tech Videos