-1
我有这样的脚本:如何添加,将只包含JSON列值
#!/bin/bash
# rsync using variables
echo 'Id,Name,Amount,TS,unique_ID' > lfs.csv
epoch=$(date +%s)
u_id=0
for ((id=1 ; ;id++))
do
[[ $u_id == 100 ]] && ((u_id = 1)) || ((u_id +=1))
echo $id",Danny_"$id","$id","$epoch","$u_id >> lfs.csv
sleep
done
,我希望能够插入一列,将代表JSON数据:
{
"totalMemory" : 12206567424,
"totalProcessors" : 4,
"version" : "0.4.1",
"startTime" : 1494851008421,
"agent" : {
"reconnectRetrySec" : 5,
"agentName" : "1002",
"checkRecovery" : false,
"backPressure" : 10000,
"throttler" : 100
},
"logPath" : "/eq/equalum/eqagent-0.4.1.0-SNAPSHOT/logs",
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"autoStart" : false,
"recovery" : {
"agentName" : "1002",
"partitionInfo" : { },
"topicToInitialCapturePosition" : { }
},
"sources" : [ ],
"upTime" : "5 min, 26 sec",
"build" : "0-SNAPSHOT",
"target" : {
"targetType" : "equalum",
"agentID" : 1002,
"engineServers" : "<some_info>",
"kafkaOptions" : null,
"eventsServers" : "<some_info>",
"jaasConfigurationPath" : null,
"securityProtocol" : "PLAINTEXT",
"stateMonitorTopic" : "_state_change",
"targetType" : "equalum",
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"serializationFormat" : "avroBinary"
}
}
和我想添加另一列代表JSON列并将包含上面的JSON字符串。 我想过如何添加列,但我的主要目的是将JSOn字符串插入到列中,我将其用作本地文件系统。
使用JSON解析器写道。 – 123
你能举个例子吗? – ErezN
网站上有数百个。 – 123