Created
April 1, 2016 03:49
-
-
Save quickgrid/bfa0de75d8cff832f7449a51e9af79ad to your computer and use it in GitHub Desktop.
The code below uses regex to read line by line and store the data read in three separate variables. The regular expression print data only for matching time within 8:00 to 10:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
c=0 | |
grep -E -w "8:[0-5][0-9]|9:[0-5][0-9]|10:00?" log.txt | while read ip time city ; do | |
echo "Logged in at $time with ip $ip and city $city " | |
c=$(( $c + 1 )) | |
echo "Found so far: $c" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment