Help on Grep in solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on Grep in solaris
# 1  
Old 10-21-2010
Help on Grep in solaris

Hi all,

I had a script which is running in HP Unix machine. Now we are migrating to Solaris
i need to run the same script which is giving me errors .

grep -iqf $PATTERN output.log
grep -vif $PATTERN2 output2.log

when i execute these in Solaris its giving me unknown option -q -f could any tell me the equivalent for this in Solaris

Thanks,
Firestar.
# 2  
Old 10-21-2010
/usr/xpg4/bin/grep supports -q and -f.
# 3  
Old 10-21-2010
@ jlligre

Thanks you.

I need one more help

in VI can you please tell me the command for search "grep" and replace with "/usr/xpg4/bin/grep" this will make my life a bit easier
# 4  
Old 10-21-2010
Code:
:g/\<grep\>/s//\/usr\/xpg4\/bin\/&/g

# 5  
Old 10-21-2010
when in VI switch press ESC to switch to command mode and then

Code:
:%s:grep:/usr/xpg4/bin/grep:gc

comment

: switch to bottom screen command line mode
% will do it in the whole file (all lines)
s substitute
: chosen as separator to avoid escaping the /
grep:/usr/xpg4/bin/grep your subtitution
: since chosen as separator
g do it globally (the replacement will take place even if more than one occurence of grep in a line
c will ask confirmation of the replacement (just press y for yes or n for no)
you can omitt the c to go faster (but more risky)

Last edited by ctsgnb; 10-21-2010 at 06:37 PM..
# 6  
Old 10-21-2010
@jlliagre

Could you please explain me what

grep -f will do .......
# 7  
Old 10-21-2010
That should be explained in the grep manual page.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep works on Linux but fails on Solaris

Hi, On linux i have the below command working fine. grep -o '<name>.*</name>' deploy.tmp | sed 's/\(<name>\|<\/name>\)//g' deploy.tmp But the same is failing on Solaris uname -a SunOS mymac 5.10 Generic_150400-23 sun4v sparc sun4v Can you tell me how can i get it work on Solaris ?... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. 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

3. Shell Programming and Scripting

Grep to display file name along with content in Solaris

Am using the following grep to match a particular patter in grep. grep xyz abc.txt now while i run this command, if the pattern matched, am getting the line containing xyz Output: xyz is doing some work Now if i want the file name also along with my output, what should i do Expected... (2 Replies)
Discussion started by: rituparna_gupta
2 Replies

4. UNIX for Dummies Questions & Answers

grep issue (Solaris)

Can anyone explain this (i.e. why the 2nd grep does not find anything)?: -bash-3.00$ cat tmp.log sftp> chdir /home/test-dir sftp> mget thosefiles*.txt File "/home/test-dir/thosefiles*.txt" not found. -bash-3.00$ grep "s*.txt" tmp.log sftp> mget thosefiles*.txt File... (4 Replies)
Discussion started by: dhebden
4 Replies

5. Solaris

grep options in solaris

Hi, I am interested in knowing the grep optiojs availabel in solaris box, to get the grep results in one line from the log files. only the matched values need to be displayed. I need ot find the values in a message where the search values will be in separate lines of the input. like:... (10 Replies)
Discussion started by: sudha143
10 Replies

6. Shell Programming and Scripting

grep -o does not work in Solaris

I am using the code below to grep through a list of files (TEMPFILE) and look for rsync, rdist, rsh, ftp, etc. in each file. Do a count of each, and output that to a logfile. This works great in Linux, but not at all in Solaris because the EGREP -o option does not exist. Anyone have an idea... (5 Replies)
Discussion started by: nitrobass24
5 Replies

7. UNIX for Dummies Questions & Answers

grep in Solaris

Hello I am trying to grep all the processes having strings "rman" and "MRTP" i.e ps -ef|grep (rman and MRTP) how can i achieve this Thankyou (7 Replies)
Discussion started by: njafri
7 Replies

8. UNIX for Dummies Questions & Answers

How to grep word + next line in solaris 10?

Hi my unix friends, How do I grep a word and next line with solaris 10. tnx Mehrdad ---------- Post updated at 03:17 PM ---------- Previous update was at 03:09 PM ---------- I found this one: cat <file_name> | awk '/<seek_word>/ {print;getline;print}' (3 Replies)
Discussion started by: mehrdad68
3 Replies

9. Solaris

grep -e doesn't work on solaris

grep -e doesn't work in Soalris. Same script with grep -e worked on AIX/HP/LINUX.. I would like to search a list of patterns on "log.txt" like ... grep -e FATAL -e ERROR log.txt I get the error message as grep: illegal option -- e Usage: grep -hblcnsviw pattern file . . . (3 Replies)
Discussion started by: jmkraja
3 Replies

10. UNIX for Dummies Questions & Answers

problems with grep on solaris 5.8

Hi all, I have a problem when i grep for a particular field among all fhe files in the directory. if i do an ls -l field * i can find it. however at the moment the number of files in the directory are close to 28000 and it returns an ksh: /usr/bin/grep: arg list too long Assuming i... (2 Replies)
Discussion started by: manualvin
2 Replies
Login or Register to Ask a Question