-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