I get a field with jq with:
jq -r '.statuses[] | "\(.name);\(.startTime);\(.ord);\(.app);\(.group)"'
It gives me:
HOSUE;20220601101600;220601;BANDOL;FLASH
I would like to get:
HOUSE;2022-06-01 10:16:00;220601;BANDOL;FLASH
Do you know if it's possible to make that with jq?
Thanks
CodePudding user response:
You can use the sub
filter:
"20220601101600" | sub("^(?<year>....)(?<mo>..)(?<day>..)(?<h>..)(?<m>..)(?<s>..)$"; "\(.year)-\(.mo)-\(.day) \(.h):\(.m):\(.s)")
CodePudding user response:
To slice by position, use the .[<from>:<to>]
notation:
.startTime | "\(.[0:4])-\(.[4:6])-\(.[6:8]) \(.[8:10]):\(.[10:12]):\(.[12:14])"