LPIC-1 Exam 101 v5 (Linux Administrator) — Question 105
Given a log file loga.log with timestamps of the format DD/MM/YYYY:hh:mm:ss, which command filters out all log entries in the time period between 8:00 am and 8:59 am?
Answer options
- A. grep -E ':08:[09]+:[09]+' loga.log
- B. grep -E ':08:[00]+' loga.log
- C. grep -E loga.log ':08:[0-9]+:[0-9]+'
- D. grep loga.log ':08:[0-9]:[0-9]'
- E. grep -E ':08:[0-9]+:[0-9]+' loga.log
Correct answer: E
Explanation
The correct answer is E because it accurately captures any entries where the minute portion of the timestamp ranges from 0 to 59 during the hour of 8. Options A and B are incorrect as they either limit the minute range or do not cover all possibilities within the hour. Options C and D are improperly formatted and do not correctly target the desired log entries.