Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Search for string  Grep

Posted on 2004-08-18
4
Medium Priority
?
397 Views
Last Modified: 2010-08-05
Problem with searching for a string.

EX:

when i do a search such as     grep keyword1.keyword2.keyword3  filetosearch
I want to get only lines that match that exact string but i get all lines that match that and any part of the string.

I've also tried  grep 'keyword1.keyword2.keyword3'  filetosearch  and grep "keyword1.keyword2.keyword3"  filetosearch
but same results each way.

How can i tell grep to ONLY give me the exact quote and nothing else.

Thanks,
0
Comment
Question by:bt707
  • 2
4 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 2000 total points
ID: 11829213
Hi bt707,

what grep are you using? I am using gnu grep 2.5.1 and it works fine even without the quotes ...
Try escaping the . with \

Sunnycoder
0
 

Author Comment

by:bt707
ID: 11829354
Hello Sunnycoder

forgot to put in, i did try to escape the . but still get same thing, not sure what version of grep, it is a new server with fresh intall of solaris 8

Thanks,
0
 
LVL 21

Expert Comment

by:tfewster
ID: 11829360
grep "^keyword1.keyword2.keyword3$"  
0
 

Author Comment

by:bt707
ID: 11829400
Hello again Sunnycoder,

It is working now, guess i was in a hurry when i did the escape, put in the wrong slash, got it now.

Thanks,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question