paries
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Heem14, you beat me by one minute!
:)
you don't even need the quotes - because the single quote is considered a word breaker.
you don't even need the quotes - because the single quote is considered a word breaker.
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:)
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:)
thanks, I appreciate the points.
grep -w ssmith dump.sql
maybe grep -iw if you need case insensitivity