lfreez lfreez - 9 months ago 43
Linux Question

Counting specific lines in a log file

I have a log file containing more than 100000 lines similar to the following

2016-11-08 17:04:01|x.x.x.x|xxxxxxxxxxxxx|x.x.x.x|1002|xxxx|xxxxxx|1|2|https://xxxxxxxxx/xxxxxxx/xxxxxxx/xxxxxx{"status":500,"body":""}
2016-11-08 17:04:02|x.x.x.x|xxxxxxxxxxxxx|x.x.x.x|1003|xxxx|xxxxxx|1|2|https://xxxxxxxxx/xxxxxxx/xxxxxxx/xxxxxx{"status":400,"body":""}

Please help me to write a script that will return a count of lines only with

Answer Source

Try grep -c "\"status\":500 /path/to/logfile.dat