-w option in fgrep for Solaris


 
Thread Tools Search this Thread
Operating Systems Solaris -w option in fgrep for Solaris
# 8  
Old 07-26-2013
Thank you Scott...it is only available in solaris 10 not below version..is it correct?
# 9  
Old 07-26-2013
That seems to be the case, yes.
# 10  
Old 07-26-2013
Several points.
one -
Code:
which fgrep

is a must to figure out which fgrep you are running.
The options are different for /usr/bin/fgrep and /usr/xpg4/bin/fgrep.

two -
/usr/xpg4/bin/grep (NOT fgrep) will do exactly what you want.

Code:
/usr/xpg4/bin/grep -F -i -w

-F means run exactly like fgrep.
It is a capital letter F.

three -
fgrep is no longer supported by POSIX. It was supposed to go away in 1997. It is there so old code will not break. All new code should consider a modern grep -F (in this case /usr/xpg4/bin/grep -F).

fgrep

four -
It is important to set your PATH to select modern commands on Solaris, by having /usr/bin/xpg4 before /usr/bin in the PATH variable. Unless you are running ancient code. Or need BSD support. You should always use nawk, not awk if you want modern behavior in awk.

Why? - any example code on the internet - especially on unix.com - will show you conforming behavior for code. When you run the old grep, fgrep, or awk then the examples will not work.
This User Gave Thanks to jim mcnamara For This Post:
# 11  
Old 07-26-2013
Quote:
Originally Posted by millan
But my concern is will /usr/sfw/bin/ggrep available in all solaris version?
Solaris 10 only. Solaris 11 has it /usr/gnu/grep. Previous releases might have it installed in /usr/local/bin/grep but there is no guarantee. There are also Solaris 10 installations when /usr/sfw/bin/ggrep is not installed but this is uncommon.
Quote:
More interestingly i cannot found any man page for this ggrep..can u pls let me know somethign about this command.
Use
Code:
man -M /usr/sfw/share/man ggrep

or add /usr/sfw/share/man to your MANPATH.

---------- Post updated at 13:07 ---------- Previous update was at 13:02 ----------

Quote:
Originally Posted by jim mcnamara
/usr/xpg4/bin/grep (NOT fgrep) will do exactly what you want.

Code:
/usr/xpg4/bin/grep -F -i -w

-F means run exactly like fgrep.
It is a capital letter F.
I'm afraid it won't. As far as I known, /usr/xpg4/bin/grep doesn't support the -w option when combined with -F given the fact it is not specified by POSIX (and that makes sense, searching a word is expected to be implemented by regular expressions while -F precisely disable regular expressions).
# 12  
Old 07-26-2013
Generally the -w option is available for grep but not egrep|fgrep.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

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. (2 Replies)
Discussion started by: manalisharmabe
2 Replies

2. Solaris

Solaris 9 : gcc unrecognized -rdynamic option

Hi all, I'm trying to compile gdb (7.4.1) 64 bit on Solaris 9 SPARC. First, I launch the configuration ~/gdb-7.4.1$>CC="gcc -m64" ./configure --disable-tui --prefix=$HOME/destdir/ Then, compilation ~/gdb-7.4.1$>make During compilation gcc (3.4.6) is not enable to recognized the option... (0 Replies)
Discussion started by: bubsland
0 Replies

3. Shell Programming and Scripting

Problem in Using fgrep Command with pattern file option

Hi, i am using fgrep command with following syntax fgrep -v -f pattern_file_name file file contains few line and have the pattern which i am giving in pattern file. My Problem is : its is not giving any output. while i am using fgrep -f pattern_file_name file it is showing all... (4 Replies)
Discussion started by: emresearch
4 Replies

4. Shell Programming and Scripting

date: illegal option -- d in sun solaris

Hi all, I am trying to execute the following command in a sun solaris machine and getting the error as below. bash-2.03$ date -d "1 day ago" +%Y%m%d date: illegal option -- d bash-2.03$ uname -a SunOS gtrd02 5.8 Generic_117350-55 sun4u sparc SUNW,Sun-Fire-V440 Can anybody help me to... (1 Reply)
Discussion started by: Tuxidow
1 Replies

5. UNIX for Advanced & Expert Users

Problem with useradd, -p option in Solaris 10

Good day all. I'm trying to add a user with useradd and the -p option to assign a project name, but the result is that the user is created with an error message: "UX: useradd: user.root name should be all lower case or numeric." The command: useradd -d /export/home/tester -g rtpgrp -G... (2 Replies)
Discussion started by: BRH
2 Replies

6. Solaris

Solaris 9 : DHCP Option 43 and 60

Hello, I need to configure a Cisco VLAN Accesspoint with DHCP using Solaris dhtadm & pntadm Network: 10.10.122.0 255.255.255.0 Default Router 10.10.122.1 Scope Range 10.10.122.10 - 254 Option 60 “Cisco AP c1142” Option 43 ... (0 Replies)
Discussion started by: fredy82
0 Replies

7. Solaris

date -d illegal option in Solaris

Hi All, Is it possible to run date -d option in Solaris? Do we have a work around so that -d option will be recognized by solaris as it is recognized by linux. I need this since i am using this in scripting and it works in Linux box. my problem is it doesn't work in solaris box. ... (6 Replies)
Discussion started by: linuxgeek
6 Replies

8. Solaris

AIX to SOLARIS conversion - (find -cmin option)

I have a piece of code (below) in a .ksh script running on AIX. I need to convert the code to run .zsh on Solaris. Solaris's find command does not support the -cmin function. Suggestions?? The code searchs for a file (_filename) and determines if it has been written to or modified in the last... (1 Reply)
Discussion started by: nmalencia
1 Replies

9. UNIX for Dummies Questions & Answers

No Password - - Setuid Only Option in Solaris 10

In Solaris 9, when I built users, there was an option for No Password -- Setuid Only. Now that I'm using Solaris 10, I no longer can find that option. Is there an equivalent option of No Password --Setuid Only in Solaris 10? Thanks, LeonD (1 Reply)
Discussion started by: leond
1 Replies

10. Programming

Solaris C compiler option -Xc

Anyone know what the -Xc option does? Is there an equivalent option for the Gnu compiler? :confused: (3 Replies)
Discussion started by: BCarlson
3 Replies
Login or Register to Ask a Question