In: Computer Science
linux: regular expressions
file name: studentsyslog.txt
Use a regular expression and grep or egrep to filter the file so the output displays only the items requested. Put your full command in the space provided.
1. Display only the lines that were written to the file between the times of 12:55 and 12:59 (inclusive). This is tricky. Don’t think of these times as numbers, think of these times as a series of characters (a 1 followed-by a 2 followed-by a colon, etc.)
grep command is used to search for a string of characters in a specified file. The text search pattern is called a regular expression
-E
controls whether you need to escape certain
special characters
The -E
is needed to have grep
understand |
(alternation) in the expression (this
alternation makes it an extended regular expression)
If you have any doubts or need ay modifications, please let me know.
grep -E '12:(55|56|57|58|59)' studentsyslog.txt
If you have any doubts, leave a comment below before rating. I'll be happy to assist you further.
Do UPVOTE this as I have put a lot of EFFORT in answering this question. It really helps me.