1

I want to capture perticular string i.e. "UPDATE kplustp..Service SET Service_Name = "PositionService", ServiceType = 'Z', HostName = "abcd" " in log file with perticular path /home/abc/xyz.log

I am using below command to do

grep -i "UPDATE kplustp..Service SET Service_Name = "PositionService", ServiceType = 'Z'" /home/adc/xyz.log 

But it is not working, may be because of special characters in string.

How to do?

user3164140
  • 591
  • 2
  • 8
  • 15

1 Answers1

0

Don't have my solaris box at hand, but try this:

grep -i 'UPDATE kplustp..Service SET Service_Name = "PositionService", ServiceType = \'Z\'' /home/adc/xyz.log 
suspectus
  • 16,548
  • 8
  • 49
  • 57
  • Sorry no success, It is giving output as Unmatched " – user3164140 Jan 20 '14 at 14:08
  • answer updated, using single quotes - and backslash to render the embedded single quotes as literals. – suspectus Jan 20 '14 at 14:37
  • Hi Thanks, it works for me. Can we capture two strings in a perticular file. For ex my 1st string is "job has started" and 2nd string is "Job completed successfully" in same log file xyz.log – user3164140 Jan 21 '14 at 10:10
  • Oh good. I don't think you can do this with one grep command. It is possible with sed. Would that do? BTW it would be nice to upvote and tick the answer - thanks. – suspectus Jan 21 '14 at 10:38