Hello All,
I am trying to count the number of users logged in a particular day using the last and filtering with 'awk, like below:
Code:
last | awk '/Mar 12/{count n++}END{print n}'
It worked fine, until I encountered a server whose wtmp contained login information more than a year. so obviously my filtering method above lists current year as well as previous year's info.
Is there any sub-programming in awk or sed to
a) print the lines that contain the pattern
b) stop parsing the file, once the line that does not contain pattern had been reached.