Skip to content

Instantly share code, notes, and snippets.

@ateucher
Last active August 29, 2015 14:15
Show Gist options
  • Save ateucher/af8b144b935af1772b08 to your computer and use it in GitHub Desktop.
Save ateucher/af8b144b935af1772b08 to your computer and use it in GitHub Desktop.
gawk - gensub
gawk -F, '
BEGIN { OFS = ",";
print "id,name,date_time,val,val2,val3"}
{
$3=gensub(/(^[0-9]{2})([A-Z]{3})([0-9]{4}):([0-9]{2}:[0-9]{2}:[0-9]{2})$/,
"\\3-\\2-\\1 \\4 PST","g",$3)
print $0
}' testfile.csv
a b 12MAY2014:01:25:00 1 2 3
c d 14JUN2012:12:32:00 4 5 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment