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

Hi,
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,
Kiran.
# 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,
Kiran.
# 4  
Old 01-05-2006
Code:
-bash-3.00$ ./kiran.sh ab 0 0 ./testfile
abc
abc
abc
-bash-3.00$ ./kiran.sh ab 0 2 ./testfile
abc
1
2
abc
1
2
abc
.
!
-bash-3.00$
-bash-3.00$ cat ./kiran.sh
#!/bin/ksh
# no -C option to grep? no fear...
# usage:
#   scriptname "searchterm" lines_before lines_after inputfile

matchstring="$1"
lines_before="$2"
lines_after="$3"
matchfile="$4"

matches=`echo "${line}" | egrep -n "${matchstring}" ${matchfile}`
if [ "$?" -ne "0" ]; then
   echo "No match" >&2
   exit 1
fi
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}
done

exit 0

So for your requirements

scriptname "searchterm" 0 <trailing_lines> filename

Cheers
ZB
# 5  
Old 01-05-2006
Hi,

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

https://www.unix.com/shell-programming-and-scripting/23992-search-file-pattern-grab-some-lines-before-pattern.html

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.

Cheers,
Kiran.
# 7  
Old 01-07-2006
Solaris 10 and below do not support it - load GNU grep on your system instead.
Where to get egrep
Login or Register to Ask a Question

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
Login or Register to Ask a Question