I want to replace all the UNIX time in a a JSON data file with the same UNIX time followed by a human readable date format.
For example, I want to replace "1234567890123456" (time in microsecond) with "1234567890123456,2009-02-14,00:31:30,sat".
I tried with
sed -r 's/([0-9]{16})/\1'"`date -d @ \1`"'/g'
but it doesn't work.
I'm new in UNIX world, can you suggest me a solution? Thank you so much.
Cordiality
I attach a sample of my JSON file:
{
"example": [
{
"query": {
"text": "string 1",
"id": [
{
"timestamp": "1234567890123456"
}
]
}
},
{
"query": {
"text": "string 2",
"id": [
{
"timestamp": "1234567891123456"
}
]
}
},
{
"query": {
"text": "string 3",
"id": [
{
"timestamp": "1234567893123456"
}
]
}
}
]
}
Copyright License:
Author:「Jean S.」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/30151378/convert-all-unix-time-in-a-file-to-human-date