Through awk am trying to get the exact match from the application log in remote server. The application log in the remote server have parenthesis. The log file is as below.
ERROR Car is not available due to error while checking car price. Error detail: (CarService.checkAvailabilityAndUpdateItinerary)
However am getting the below error. Could you please help.
ssh user@hostip awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"
Passing ssh arguments has the principle problem that they are interpreted (and expanded) twice, once on the calling site and once on the called site.
In this simple case you can nest two types of quotes
ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"'
More robust is a here document, and passing the script through stdin
ssh user@hostip /bin/sh << "EOT"
awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"
EOT
The quotes around the terminating EOT do minimal expansion on the calling site.
Thanks for the reply.
I followed the first approach the result is getting as Zero. We do have the said pattern in the remote server.
ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/" ' /home/folder1/file.log | wc -l
##########################################################
###########################################################
0
The outer 'string' must contain the entire remote command(s)
ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/" /home/folder1/file.log | wc -l'