Convert field from epoch to human readable
Hi,
I have a file as follows: Code:
10.129.187.1 1325914841 98-4B-4A-E4-AA-0E 10.129.89.194 * * Code:
awk 'BEGIN {$2=strftime("%c",$2)} {print}' myfile Please could you help to do it? Thanks in advance! |
Hello,
It would have to be like follows: Code:
awk '{$2=strftime("%c",$2)} {print $2}' myfile Josh |
Noticed you gave me rep; Did that help and/or solve your problem? If so, could you kindly mark your thread as solved using the thread tools located at the top of the page? Thanks!
Cheers, Josh |
You can simplify as well if you wish to print the whole line:
Code:
awk '$2=strftime("%c",$2)' file |
An aside note: awk here is useful to extract the 2nd field from a file, but in general, you can convert from epoch to calendar date using the GNU date command, example:
Code:
$ date -ud @1325914841 |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 04:45 AM. |