If the Unix timestamps in the file could be prefixed by @
, then GNU date
could read them in with -f
. We may prefix each timestamp with @
using sed
like so:
sed 's/^/@/' file
... and we may then use the output of that with GNU date
like so:
date -f <(sed 's/^/@/' file)
Given the datestamps in question and my local timezone, this would give us
Wed Mar 22 02:53:29 CET 2023
Wed Mar 22 02:53:34 CET 2023
Wed Mar 22 02:53:38 CET 2023
Wed Mar 22 02:53:38 CET 2023
Wed Mar 22 02:53:42 CET 2023
Wed Mar 22 02:53:43 CET 2023
Wed Mar 22 02:53:44 CET 2023
Wed Mar 22 02:53:44 CET 2023
Wed Mar 22 02:53:53 CET 2023
Wed Mar 22 02:54:03 CET 2023
Wed Mar 22 02:54:06 CET 2023
Wed Mar 22 02:54:20 CET 2023
Wed Mar 22 02:54:25 CET 2023
Wed Mar 22 02:54:31 CET 2023
You may then set the output format you want as you would usually do with date
. Here I also show how to use an ordinary pipe instead of a process substitution:
$ sed 's/^/@/' file | date -f - +'%F %T'
2023-03-22 02:53:29
2023-03-22 02:53:34
2023-03-22 02:53:38
2023-03-22 02:53:38
2023-03-22 02:53:42
2023-03-22 02:53:43
2023-03-22 02:53:44
2023-03-22 02:53:44
2023-03-22 02:53:53
2023-03-22 02:54:03
2023-03-22 02:54:06
2023-03-22 02:54:20
2023-03-22 02:54:25
2023-03-22 02:54:31
See the manual for the library function strftime
(man 3 strftime
) to see what format placeholders you may use.