Bash 在jq中的最后一列上应用strftime

Bash 在jq中的最后一列上应用strftime,bash,timestamp,unix-timestamp,jq,Bash,Timestamp,Unix Timestamp,Jq,我正在处理一个文件并从中筛选出某些字段。然后,我将整个结果转换为CSV文件。但是,我要过滤掉的最后一列是历元时间戳(最高毫秒) 我四处搜索,发现我可以使用jq中的strftime函数进行转换;在整个数组中应用| strftime时,它将函数应用于所有值 TZ='Asia/Kolkata' grep $id ~/hhfh.log | grep -oE '\{.+' | jq -r '[.highPrice, .lowPrice, .openPrice, .closePrice, .volu

我正在处理一个文件并从中筛选出某些字段。然后,我将整个结果转换为CSV文件。但是,我要过滤掉的最后一列是历元时间戳(最高毫秒)

我四处搜索,发现我可以使用jq中的
strftime
函数进行转换;在整个数组中应用
| strftime
时,它将函数应用于所有值

TZ='Asia/Kolkata'  grep $id ~/hhfh.log  |  grep -oE '\{.+' | jq  -r '[.highPrice, .lowPrice, .openPrice, .closePrice, .volumeTradedToday, .totalBuyQuantity, .totalSellQuantity, .tickTimestamp | strftime("%B %d %Y %I:%M%p %Z")]' | jq -r 'map(tostring) | join(", ")'
我是否可以修改此选项,使
strftime(“%B%d%Y%I:%M%p%Z”)
仅适用于
.tickTimestmap
值?如果不是,我是否必须依赖于
awk


hhfh.Log
记录行:

2018-03-06 03:30:04,938 DEBUG KiteTickerSourceLogic [ReadingThread] TickData: {"mode":"full","tradable":false,"instrumentToken":2997505,"lastTradedPrice":740.0,"highPrice":0.0,"lowPrice":0.0,"openPrice":731.5,"closePrice":739.9,"change":0.01351533991080183,"lastTradedQuantity":23.0,"averageTradePrice":0.0,"volumeTradedToday":12.0,"totalBuyQuantity":285.0,"totalSellQuantity":1469.0,"lastTradedTime":1520245282000,"oi":0.0,"tickTimestamp":1520307004000,"openInterestDayHigh":0.0,"openInterestDayLow":0.0,"marketDepth":{"buy":[{"quantity":1,"price":735.55,"orders":1},{"quantity":86,"price":731.5,"orders":1},{"quantity":168,"price":731.0,"orders":1},{"quantity":25,"price":730.1,"orders":1},{"quantity":0,"price":0.0,"orders":0}],"sell":[{"quantity":550,"price":743.6,"orders":1},{"quantity":550,"price":746.6,"orders":1},{"quantity":10,"price":750.0,"orders":1},{"quantity":25,"price":777.0,"orders":1},{"quantity":12,"price":-0.01,"orders":1}]}}
我目前正在生成的内容:

January 01 1970 12:05:08AM UTC, January 01 1970 12:05:02AM UTC, January 01 1970 12:05:04AM UTC, January 01 1970 12:05:06AM UTC, January 19 1970 08:56:53AM UTC, January 01 1970 04:39:20AM UTC, January 01 1970 12:00:00AM UTC, August 31 50144 10:33:20AM UTC
它应该是什么样的:

751.95, 734.1, 745.45, 742.8, 1659987, 6358, 0, <time in IST zone>
751.95734.1745.45742.816599876358,0,

只需使用括号:

 (.tickTimestamp | strftime("%B %d %Y %I:%M%p %Z"))

如果您想要相对于TZ的时间,请使用
strflocaltime
,但它需要比1.5更新版本的jq。

它不遵守
TZ='Asia/Kolkata'
时区。有办法解决吗?系统时区为UTC。解析的时间输出也为UTC立即,例如,
1520245622000
的值应给出:
2018年3月5日星期一15:57:02 IST
(使用
日期-d
);虽然是2018年3月5日10:27:02 UTC,但使用strflocaltime需要比1.5更新的jq版本。除了从源代码编译jq,还有其他选择吗?