How can I convert timestamps in a column to a date?
Found something here: Stackoverflow - Convert from unixtime at command line.
Came up with this:
awk -F"," '{OFS=","; $1=strftime("%Y-%m-%d %H:%M:%S", $1); print $0}' file
-F","
to use a field separator of,
,OFS=",";
so that the output fields are also separated by a,
,$1=strftime("%Y-%m-%d %H:%M:%S", $1);
to change the value of the first field$1
into the specified format, andprint $0;
to print the whole line.
Like this perhaps
perl -pe 'use POSIX qw(strftime); s/^(\d+)/strftime "%F %H:%M:%S", localtime($1)/e'
If you like awk
you can use external command date
with any date formats
awk -F, -v OFS="," '{("date +%F\ %T -d @"$1)|getline $1}1'