Issue
I am searching a kubernetes pod logs for the pattern “variable=value” ( e.g., variable=10 or variable=500) using the command below:
Kubectl logs -f | grep “variable=”
My question is that wether it is possible to modify the command above in order to return the logs where the variable value is greater than some threshold, e.g, for threshold=300
, variable=301
, variable=302
would be filetered in, but variable=299
would be filtered out
I know I can develop a small program for this, but rather I want a rapid solution in the command line direcly without the hassle of writing a small prgram.
Solution
You didn't provide any sample input so it's a guess but this may be what you're trying to do:
awk -F'=' '($1=="variable") && ($2>300)' file
If that's not all you need then please edit your question to include a Minimal, Reproducible Example with concise, testable sample input, expected output and your attempt to solve the problem yourself so we can help you further. See [ask] and look at existing questions that have been upvoted and answered for examples.
Answered By - Ed Morton Answer Checked By - Gilberto Lyons (WPSolving Admin)