I have a log file I am trying to pull data from. It is formatted like so, and lists when certain modules are checked in and out:
19:50:26 (license_manager) OUT: "certain_module" email@example.com 19:50:28 (license_manager) IN: "rarely_used_module" firstname.lastname@example.org 19:50:28 (license_manager) IN: "certain_module" email@example.com 19:50:28 (license_manager) IN: "different_module" firstname.lastname@example.org 19:50:38 (license_manager) OUT: "certain_module" email@example.com 19:50:38 (license_manager) OUT: "different_module" firstname.lastname@example.org
So far I have the following. I am specifically interested in when the "rarely_used_module" is getting checked out and by whom:
cd /path/to/script && cat logfile.txt | grep -c "rarely_used_module"
That just gives me the count, though, and nothing else. I would like to make this more sophisticated for two reasons: to learn more about shell scripting and to implement a greater amount of bash concepts into this script, secondly, I would like it to be able to tell me what time the license was checked out and what user checked it out.
The absolute ideal situation would be to count the number of times this license was checked out and format it into some sort of table for reference. Is this possible?
Desired output, something like the following. I'm going to pose a theoretical example below in which the rarely_used_module has been checked out 4 times by 2 unique users, 2 separate times:
Number of license checkouts for rarely_used_module: 4 User : email@example.com (2) User : firstname.lastname@example.org (2)
Essentially I want the number of times the module has been checked out, total, and I want the names of the users that have checked this license out. I know I can grab the OUT: line for "rarely_used_module" but I'm not sure how to work that in.