bash - Need regex to remove a character in a datetime string in csv file -


i have csv file has following string:

"2016-10-25t14:07:49.298-07:00" 

which replace with:

"2016-10-25", "14:07:49" 

i matched original string regular expression:

([0-9]{4}-[0-9]{2}-[0-9]{2})[t]([0-9]{2}\:[0-9]{2}\:[0-9]{2})\.[0-9]{3}-07\:00 

but need help

with awk, assuming t , . unique

$ echo '"2016-10-25t14:07:49.298-07:00"' | awk -f'[t.]' '{print $1 "\", \"" $2 "\""}' "2016-10-25", "14:07:49" 
  • -f'[t.]' assign t or . field separator
  • then print first , second field required formatting

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -