linux - Edit field with date in .csv -
i have .csv file lines this:
xxxx,xxxxxx,sep 1, 2015 21:32:15.xxxxxxxxx west xxxx,xxxxxx,sep 28, 2015 23:46:16.xxxxxxxxx west xxxx,xxxxxx,sep 30, 2015 21:23:17.xxxxxxxxx west
and need change date , time this:
xxxx,xxxxxx,2015-09-01,21:32:15 xxxx,xxxxxx,2015-09-28,23:46:16 xxxx,xxxxxx,2015-09-30,21:23:17
i think it's possible using awk , date until nothing worked.
some perl:
perl -mtime::piece -f, -lape ' ($d2, $d1) = (pop(@f), pop(@f)); $d2 =~ s/\..*//; push @f, time::piece->strptime($d1.$d2, "%b %e %y %t")->strftime("%y-%m-%d,%t"); $_ = join ",", @f; ' file
that removes last 2 comma-separated fields each line, deletes fractional time , timezone, reformats time , prints.
Comments
Post a Comment