I'm trying to scan an error log for lines with 503 errors, so I'm grepping for " 503
(quote space 503).
This seems simple, but it won't work:
grep '" 503 ' access.log
I get the following error:
bash: -c: line 0: unexpected EOF while looking for matching `"' bash: -c: line 1: syntax error: unexpected end of file
Seems like you are running it via some system() in some language, aren't you? Try:
grep '\" 503 ' access.log
or:
grep "\" 503 " access.log
Directly in shell just grep '" 503 ' access.log
will work. To reproduce your problem I must do:
bash -c 'grep '\" 503 ' access.log'
This is indeed syntax error. To make that work, I need:
bash -c 'grep "\" 503 " access.log'
You are somehow calling bash -c ...
. Maybe indirectly. You need to figure you how it's called to figure out what quotes are in collision.
I believe I have it working now (not sure because I got no results, but didn't get an error).
The reason is because I'm passing it through an ssh command like the following and I believe SSH is doing some escape trickery:
ssh 123.123.123.123 grep '" 503 ' access.log
Modifiying it to this seems to be the fix:
ssh 123.123.123.123 "grep '\" 503 ' access.log"
Thanks for everyone's time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With