Display lines of two date range from syslog file
Hi Guys,
I want to display lines from Solaris syslog file but with 2 dates range. I have some similar solution (http://www.unix.com/shell-programmin...2-dates-4.html) which works fine but as you know syslog has different date format (Jan 22) so this is not running in such format. Can somebody help me in this please? |
The link provided doesn't work.
Are you looking for something like this: Code:
sed -n '/Jul 2 09:28:23/,/Jul 2 09:40:01/p' syslog |
Quote:
|
Quote:
We cannot help you if you don't give us any information. Also: What about the link you posted, can you fix that so we can have a look at what it is you are referring to. |
One problem with lines like the sed one above is that it can only match exact times. But what if you want everything from 2pm to 4pm say, but the first entry is 2:01pm? You need to be able to make relative matches.
Gnu awk has a selection of time functions that can make this kind of thing easier, but it still requires a bit of work: http://www.gnu.org/software/gawk/man...-Functions.htm There are also solutions using perl and other languages. I'm sure you can find lots of info on the net if you look. Finally, there are various tools others have written. The date utilities here include one called dgrep that's designed just for this kind of thing: http://www.fresse.org/dateutils/ |
All times are GMT -5. The time now is 07:17 PM. |