Shell Script: Epoch Time to Human Readable Time

Log files are sometimes written with epoch timestamps. To analyse the log file entries, we will first need to convert the time to a human readable format. In this article, we will look at a few available methods to convert the epoch time to real time or human readable time.

Epoch Time to Human Readable Time with GNU Date

On Linux or any system with the GNU date installed, just specify the “--date” option to the date command. If the epoch time is 1414828800, we covert it to a human readable format like this.

Epoch Time to Human Readable Time with Perl

The Solaris date command does not support the --date option. So, we will need to use perl.

Epoch Time to Human Readable Time with Python

Python can also be used to convert the epoch time to a human readable format. On Python 2.x, use the following syntax.

On Python 3.x, use the new syntax below.

Epoch Time to Human Readable Time with Awk

The final method is to use the pattern scanning and text processing tool – awk.

If awk complains about strftime, try using gawk instead.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }