Sorry, couldn't really think of a simple subject/title.
So, I have a log file, and the dates are displayed like so:
2009-03-05 02:49:44
So the first and second field are the date/time. I can change them into a unix timestamp easily with:
date -d "2009-03-05 02:49:44" +%s
However, trying to do that is not as easy as I thought. I wanted to get all logs between X and Y time (lets say for a few hours on Z day). To make this easily reusable, I would rather do it this way.
I have tried to use awk with the system() function, but maybe I did not use it correctly..
awk '{ system("date -d " $1,$2 " +%s"); }'
Of course, I have tried other varieties of this, but to no avail. I have thought of possibly doing it other ways, but I am not even sure what will work now.. Anyone have any suggestions?
@Haris, this is another problem than the OP. But however, here is a possible solution depending on your distribution. This one is using GNU coreutils date command.
dte=05032009
dteIso=$(echo $dte | sed 's/\(..\)\(..\)\(....\)/\3\2\1/')
LC_ALL=C date -d $dteIso +'%d %B %Y'
@ haris this is the third time you post the very same question on someone else's post. I have replied to your problem here:
Parsing log files, displaying logs between specific dates
first see to it that ur code works properly on HP-UX
i m not a mad guy nor i get pleasure by asking the same question
i want to be a part of this sight so dont do such things which might cost me
this is bcoz of u
Reason: Thread hijacking
-------
-------
This infraction is worth 2 point(s) and may result in restricted access until it expires. Serious infractions will never expire.
so pls i urge u not u put such responses if u cant help me or provide proper sol its ok
sorry i will keep this in mind.but dont know how to post a new thread from starting
bcoz i knw only way from where u can post a thread that is at the bottom of already existing post i.e through post reply.
could u please let me knw the exact path from where i can post a new thread from starting as i m very new to this forum n never posted any thread from starting.