

To get data between a range of date examples from 01 Dec to 10 Dec, use the below command. The Parameters -E is called extended-regex that is used to set patterns and lastly, you need to provide a log file or log directory. A grep is used to search regular patterns in the provided file.

Now we will explain to you, how this command works “ grep”. I’ll show a few examples using grep like I want to check the log for Today, then I’ll pass the below command. If you want to check the log more easily and in a simple way, then you can follow the grep command utility. Replace start=HH:MM with starting hour and minute, stop=HH:MM with final hour and minute. Sample Output Dec 11 19:39:19 LINUX dbus-daemon: Activating via systemd: service name='1' unit='rvice' requested by ':1.3' (uid=1000 pid=2740 comm="/usr/libexec/tracker-miner-fs " label="unconfined")ĭec 11 19:39:19 LINUX systemd: Starting Tracker metadata database store and lookup manager.ĭec 11 19:39:19 LINUX systemd: session-23.scope: Succeeded.ĭec 11 19:39:19 LINUX dbus-daemon: Successfully activated service '1' Filter Data Using the Awk Commandįirst, we filter the Syslog file based on the time range using the awk command as shown. Today, we will filter /var/log/syslog file based on date range using both awk and grep command-line tools. While grep is a simple pattern tool that searches for patterns using a regular expression. The awk is a popular command-line tool used to manipulate data in files and generate a report based on a given pattern in the Linux system. But when you want to filter data in an organized way based on time, then we use awk, grep, and sed commands. Simply doing cat to read a log file is a kinda basic way to inspect a log file.

If you are facing difficulty while systematically reading log files in Linux.
