background img
banner
Dec 26, 2013
216 Views
0 0

Finding the number of lines of unique string in a file for specific duration- Linux

Written by
banner

One day , I gone though a scenario where I have to count the number of lines of error string in a file for specific duration in the linux server using single command. I require it as I will be repeating it for multiple iterations of testing cycle.
As I did not have much experience in linux commands , I spent more time in browsing various web pages and finally I was able to join the commands in order to get one line command.

sample

 

 

 

 

 

 

I think this might be useful to many testers like me

Linux command for finding number of lines of unique string in a file for specific duration:
sed -n ‘/2013-12-24 20:20:00/,/2013-12-24 23:59:59 /p’ logfile.log | grep ‘error’ | wc -l

Or you can use this as well for quick view,
grep -i ‘error’ filename.log

Here You can update any string that has to be searched in grep ‘error’

Article Categories:
Performance Testing
banner

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.