Covert epoch to a human readable format using awk

An awk one-liner to convert epoch time to a human readable format.

[[email protected] ~]$ cat epoch.txt
1587481133.293749	CYURHdG5l4jBhU1jb
1587481188.990734	CRgwN2HC3jQPMa7sb
1587481193.855005	Cvlbme4NPPzsfSt6b5
1587481189.016330	C7obDf1jt8z1KHjqj3
1587481194.005504	CF9KYf1gWR62iFMNne
1587481139.029608	CWzDwP38CVCi6Q51Mc
1587481194.031021	CRpEsP2TI9RakOH3x8
1587481193.930650	CeaRrR2MW98BzDcHB2
1587481194.038082	CuFe7L1WmdK38RZOH5
1587481193.821363	CZPKMp1CnuZuxBwsI3
1587480835.925876	CspNB64hKD2dr8fWv6
1587481060.840924	CpSIYC39p9q3lAZxG2
[[email protected] ~]$ cat epoch.txt | awk '{ printf "%s -- %s\n", strftime("%F %T",$1), $0 }'
2020-04-21 09:58:53 -- 1587481133.293749	CYURHdG5l4jBhU1jb
2020-04-21 09:59:48 -- 1587481188.990734	CRgwN2HC3jQPMa7sb
2020-04-21 09:59:53 -- 1587481193.855005	Cvlbme4NPPzsfSt6b5
2020-04-21 09:59:49 -- 1587481189.016330	C7obDf1jt8z1KHjqj3
2020-04-21 09:59:54 -- 1587481194.005504	CF9KYf1gWR62iFMNne
2020-04-21 09:58:59 -- 1587481139.029608	CWzDwP38CVCi6Q51Mc
2020-04-21 09:59:54 -- 1587481194.031021	CRpEsP2TI9RakOH3x8
2020-04-21 09:59:53 -- 1587481193.930650	CeaRrR2MW98BzDcHB2
2020-04-21 09:59:54 -- 1587481194.038082	CuFe7L1WmdK38RZOH5
2020-04-21 09:59:53 -- 1587481193.821363	CZPKMp1CnuZuxBwsI3
2020-04-21 09:53:55 -- 1587480835.925876	CspNB64hKD2dr8fWv6
2020-04-21 09:57:40 -- 1587481060.840924	CpSIYC39p9q3lAZxG2

comments powered by Disqus