A few days ago I made one of these small discoveries that make you smile and at the same time cry for all the time you have lost.
And one more time I got a reminder that mastering unix tools can make your life easier. God save the
I was trying to debug an error in production. An ajax call was failing randomly (aparently) with a 500 but I couldn’t figure out how to reproduce it, so my plan was to navigate around the page until I can understand what kind of parameters make the ajax call fail.
The fastest way to see that is look at the log.
The aplication has a pooling service that pollutes the log with a lot of requests that doesn’t matter to me and makes impossible to find anything.
So I piped the output of the tail command to grep
Fail again. I see all the errors but I don’t see the the context, so I can’t know which action failed or what parameters made the request fail.
But unix always surprises me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
There is many more options, but the important options here are
-C. With this options you can show the context around the matchings.
That command shows 2 lines before and 5 after the matching.
It worked like a charm!