-w option in fgrep for Solaris


 
Thread Tools Search this Thread
Operating Systems Solaris -w option in fgrep for Solaris
# 1  
Old 07-26-2013
-w option in fgrep for Solaris

I want to use fgrep for a word serch ignoring case and it should dispaly word count along with the file name.

I m using below code

Code:
 
fgrep -wci string filenames

But it is giving error

Code:
 
Usage:  fgrep [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        fgrep [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]

I have checked the man page and found i cannot use -w option along with fgrep.

And i dont want to use grep because i have a lage no of strings to search so for performance gain i want to use fgrep.

Could you please suggest how do i implement this.
# 2  
Old 07-26-2013
I think that there is more than one grep executable installed on Solaris. Try the one not on your path. You may have to find / -name "grep" to find it and then fully qualify the path name when you want to use it in your script with the -w flag.



Robin
# 3  
Old 07-26-2013
Try:
Code:
/usr/sfw/bin/ggrep -Fwci string filenames

# 4  
Old 07-26-2013
There is another grep in path /usr/xpg4/bin/grep.

But it is also giving same error..not allowing to use -F option alongwith -w option.

Code:
 
bash-3.00$ time /usr/xpg4/bin/grep -F -c -iw completed db*.log
Usage:  grep [-c|-l|-q] [-bhinsvwx] pattern_list [file ...]
        grep [-c|-l|-q] [-bhinsvwx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -E [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -E [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -F [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -F [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]

# 5  
Old 07-26-2013
Did you read post #3 at all?
# 6  
Old 07-26-2013
Thank you jlliagre.. I tried your code...it is working perfectly

Code:
 
/usr/sfw/bin/ggrep -Fwci string filenames

But my concern is will /usr/sfw/bin/ggrep available in all solaris version?

Because my script will run on different solaris server on different clients...or is it available on a particular version.

More interestingly i cannot found any man page for this ggrep..can u pls let me know somethign about this command.
# 7  
Old 07-26-2013
https://www.unix.com/302837053-post3.html

It's GNU grep. Check the man page for that.
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