need help grep'g

wow this is embarrasing

i have an sql file that is monsterous.

i need to getout all the sql statements that have 'ssmith' , This includes those surrounding single qoutes. there are many smiths and words with smith in them.

I tried

grep ''ssmith'' dump.sql (thats two single qoutes)
grep "'ssmith'" dump.sql
grep "\'ssmith\'" dump.sql (finds nothing)

they all still find stuff like melissasimmonssmith

please help
pariesAsked:
Who is Participating?
 
sda100Commented:
Hi paries

grep -w "'ssmith'" dump.sql

... is the one you need (double-quotes surrounding single-quotes).  The -w is to match at word boundaries.

Steve :)
0
 
Heem14Commented:
try

grep -w ssmith dump.sql

maybe grep -iw if you need case insensitivity
0
 
sda100Commented:
Heem14, you beat me by one minute!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Heem14Commented:
:)

you don't even need the quotes - because the single quote is considered a word breaker.
0
 
pjedmondCommented:
Another approach is to:

cat dump.sql | grep -e "[ ']ssmith[ ']" > output.txt

Using > to send to the output file,
or >> to append to the output file.

The above statment breaks down your requirement really easily. First cat the file concerned ,then get lines that have either a space or ' followed by ssmith and then followed by either a space or '. Obviously you can:

grep -e "[ ']ssmith[ ']" dump.sql

But looking at the structure of the above command it is easier to understand and manage, without having to resort to:

man grep

Also the above structure is more versatile for other scenarios that you might encounter.

HTH:)
0
 
Heem14Commented:
thanks, I appreciate the points.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.