- 论坛徽章:
- 1
|
本帖最后由 guobaofu 于 2019-08-21 15:20 编辑
回复 3# cfwyy
hi,我测试过你的sed命令和脚本,对于我上面的源文件输出可以,但是我的json文件内容比那个多,我测试输出有问题。
json.txt
- {
- "Components": {
- "msgprocessors": [
- {
- "processor": "eshop-retryOrder-fail-processor",
- "active": true
- },
- {
- "processor": "eshop-order-processor",
- "active": true
- },
- {
- "processor": "ch-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "pt-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "be-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "pt-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "ch-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "uk-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "eshop-retryAppointment-fail-processor",
- "active": true
- },
- {
- "processor": "be-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "uk-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "eshop-appointment-processor",
- "active": true
- },
- {
- "processor": "uk-priority-retry-outbound-sampling",
- "active": true
- }
- ],
- "endpoints": [
- {
- "endpoint": "activeprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "api-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "be-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "ch-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "drools_antifraud",
- "active": true
- },
- {
- "endpoint": "drools_appointment_lateness",
- "active": true
- },
- {
- "endpoint": "drools_bioqueue",
- "active": true
- },
- {
- "endpoint": "drools_dynamic_endpoint",
- "active": true
- },
- {
- "endpoint": "endpoint-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "eshop-out-appointment-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop-out-order-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop_token_endpoint",
- "active": true
- },
- {
- "endpoint": "lb-be-encrypt-endpoint",
- "active": true
- },
- {
- "endpoint": "msgprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "pt-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "queue-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "servicegroup-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "tlsconnect_appointment_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_order_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_tma",
- "active": true
- },
- {
- "endpoint": "uk-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "uk-hone1adapter-outbound-endpoint",
- "active": true
- }
- ],
- "services": [
- {
- "service": "pt-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-file-processor-service",
- "active": true
- },
- {
- "service": "uk-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-hone1adapter-outbound-service",
- "active": true
- },
- {
- "service": "Version",
- "active": true
- }
- ],
- "apis": [
- {
- "api": "appointmentLateness",
- "active": true
- },
- {
- "api": "bioqueue",
- "active": true
- },
- {
- "api": "pt-emetrics_TLS2PortugalAPI",
- "active": true
- },
- {
- "api": "order",
- "active": true
- },
- {
- "api": "be_token",
- "active": true
- },
- {
- "api": "GenericRulesEngineAPI",
- "active": true
- },
- {
- "api": "tma",
- "active": true
- },
- {
- "api": "sre",
- "active": true
- },
- {
- "api": "esbHealthCheckAPI",
- "active": true
- }
- ]
- }
- }
复制代码
cat json.txt|sed -E 's/(\]),/\1\n\}\n\{/'
输出结果:
- {
- "Components": {
- "msgprocessors": [
- {
- "processor": "eshop-retryOrder-fail-processor",
- "active": true
- },
- {
- "processor": "eshop-order-processor",
- "active": true
- },
- {
- "processor": "ch-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "pt-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "be-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "pt-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "ch-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "uk-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "eshop-retryAppointment-fail-processor",
- "active": true
- },
- {
- "processor": "be-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "uk-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "eshop-appointment-processor",
- "active": true
- },
- {
- "processor": "uk-priority-retry-outbound-sampling",
- "active": true
- }
- ]
- }
- {
- "endpoints": [
- {
- "endpoint": "activeprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "api-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "be-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "ch-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "drools_antifraud",
- "active": true
- },
- {
- "endpoint": "drools_appointment_lateness",
- "active": true
- },
- {
- "endpoint": "drools_bioqueue",
- "active": true
- },
- {
- "endpoint": "drools_dynamic_endpoint",
- "active": true
- },
- {
- "endpoint": "endpoint-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "eshop-out-appointment-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop-out-order-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop_token_endpoint",
- "active": true
- },
- {
- "endpoint": "lb-be-encrypt-endpoint",
- "active": true
- },
- {
- "endpoint": "msgprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "pt-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "queue-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "servicegroup-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "tlsconnect_appointment_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_order_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_tma",
- "active": true
- },
- {
- "endpoint": "uk-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "uk-hone1adapter-outbound-endpoint",
- "active": true
- }
- ]
- }
- {
- "services": [
- {
- "service": "pt-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-file-processor-service",
- "active": true
- },
- {
- "service": "uk-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-hone1adapter-outbound-service",
- "active": true
- },
- {
- "service": "Version",
- "active": true
- }
- ]
- }
- {
- "apis": [
- {
- "api": "appointmentLateness",
- "active": true
- },
- {
- "api": "bioqueue",
- "active": true
- },
- {
- "api": "pt-emetrics_TLS2PortugalAPI",
- "active": true
- },
- {
- "api": "order",
- "active": true
- },
- {
- "api": "be_token",
- "active": true
- },
- {
- "api": "GenericRulesEngineAPI",
- "active": true
- },
- {
- "api": "tma",
- "active": true
- },
- {
- "api": "sre",
- "active": true
- },
- {
- "api": "esbHealthCheckAPI",
- "active": true
- }
- ]
- }
- }
复制代码
jq输出有问题啊cat json-out.txt |jq -c
parse error: Expected separator between values at line 58, column 1
希望输出结果是这样子:
- {
- "msgprocessors": [
- {
- "processor": "eshop-retryOrder-fail-processor",
- "active": true
- },
- {
- "processor": "eshop-order-processor",
- "active": true
- },
- {
- "processor": "ch-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "pt-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "be-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "pt-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "ch-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "uk-biometrics-inbox-processor",
- "active": true
- },
- {
- "processor": "eshop-retryAppointment-fail-processor",
- "active": true
- },
- {
- "processor": "be-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "uk-retry-outbound-sampling",
- "active": true
- },
- {
- "processor": "eshop-appointment-processor",
- "active": true
- },
- {
- "processor": "uk-priority-retry-outbound-sampling",
- "active": true
- }
- ]
- }
- {
- "endpoints": [
- {
- "endpoint": "activeprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "api-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "be-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "ch-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "drools_antifraud",
- "active": true
- },
- {
- "endpoint": "drools_appointment_lateness",
- "active": true
- },
- {
- "endpoint": "drools_bioqueue",
- "active": true
- },
- {
- "endpoint": "drools_dynamic_endpoint",
- "active": true
- },
- {
- "endpoint": "endpoint-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "eshop-out-appointment-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop-out-order-endpoint",
- "active": true
- },
- {
- "endpoint": "eshop_token_endpoint",
- "active": true
- },
- {
- "endpoint": "lb-be-encrypt-endpoint",
- "active": true
- },
- {
- "endpoint": "msgprocessor-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "pt-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "queue-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "servicegroup-admin-serviceEP",
- "active": true
- },
- {
- "endpoint": "tlsconnect_appointment_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_order_endpoint",
- "active": true
- },
- {
- "endpoint": "tlsconnect_tma",
- "active": true
- },
- {
- "endpoint": "uk-filedecrypt-service-endpoint",
- "active": true
- },
- {
- "endpoint": "uk-hone1adapter-outbound-endpoint",
- "active": true
- }
- ]
- }
- {
- "services": [
- {
- "service": "pt-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-file-processor-service",
- "active": true
- },
- {
- "service": "uk-filedecrypt-service",
- "active": true
- },
- {
- "service": "uk-hone1adapter-outbound-service",
- "active": true
- },
- {
- "service": "Version",
- "active": true
- }
- ]
- }
- {
- "apis": [
- {
- "api": "appointmentLateness",
- "active": true
- },
- {
- "api": "bioqueue",
- "active": true
- },
- {
- "api": "pt-emetrics_TLS2PortugalAPI",
- "active": true
- },
- {
- "api": "order",
- "active": true
- },
- {
- "api": "be_token",
- "active": true
- },
- {
- "api": "GenericRulesEngineAPI",
- "active": true
- },
- {
- "api": "tma",
- "active": true
- },
- {
- "api": "sre",
- "active": true
- },
- {
- "api": "esbHealthCheckAPI",
- "active": true
- }
- ]
- }
复制代码
cat json-out.txt |jq -c
- {"msgprocessors":[{"processor":"eshop-retryOrder-fail-processor","active":true},{"processor":"eshop-order-processor","active":true},{"processor":"ch-retry-outbound-sampling","active":true},{"processor":"pt-retry-outbound-sampling","active":true},{"processor":"be-biometrics-inbox-processor","active":true},{"processor":"pt-biometrics-inbox-processor","active":true},{"processor":"ch-biometrics-inbox-processor","active":true},{"processor":"uk-biometrics-inbox-processor","active":true},{"processor":"eshop-retryAppointment-fail-processor","active":true},{"processor":"be-retry-outbound-sampling","active":true},{"processor":"uk-retry-outbound-sampling","active":true},{"processor":"eshop-appointment-processor","active":true},{"processor":"uk-priority-retry-outbound-sampling","active":true}]}
- {"endpoints":[{"endpoint":"activeprocessor-admin-serviceEP","active":true},{"endpoint":"api-admin-serviceEP","active":true},{"endpoint":"be-filedecrypt-service-endpoint","active":true},{"endpoint":"ch-filedecrypt-service-endpoint","active":true},{"endpoint":"drools_antifraud","active":true},{"endpoint":"drools_appointment_lateness","active":true},{"endpoint":"drools_bioqueue","active":true},{"endpoint":"drools_dynamic_endpoint","active":true},{"endpoint":"endpoint-admin-serviceEP","active":true},{"endpoint":"eshop-out-appointment-endpoint","active":true},{"endpoint":"eshop-out-order-endpoint","active":true},{"endpoint":"eshop_token_endpoint","active":true},{"endpoint":"lb-be-encrypt-endpoint","active":true},{"endpoint":"msgprocessor-admin-serviceEP","active":true},{"endpoint":"pt-filedecrypt-service-endpoint","active":true},{"endpoint":"queue-admin-serviceEP","active":true},{"endpoint":"servicegroup-admin-serviceEP","active":true},{"endpoint":"tlsconnect_appointment_endpoint","active":true},{"endpoint":"tlsconnect_order_endpoint","active":true},{"endpoint":"tlsconnect_tma","active":true},{"endpoint":"uk-filedecrypt-service-endpoint","active":true},{"endpoint":"uk-hone1adapter-outbound-endpoint","active":true}]}
- {"services":[{"service":"pt-filedecrypt-service","active":true},{"service":"uk-file-processor-service","active":true},{"service":"uk-filedecrypt-service","active":true},{"service":"uk-hone1adapter-outbound-service","active":true},{"service":"Version","active":true}]}
- {"apis":[{"api":"appointmentLateness","active":true},{"api":"bioqueue","active":true},{"api":"pt-emetrics_TLS2PortugalAPI","active":true},{"api":"order","active":true},{"api":"be_token","active":true},{"api":"GenericRulesEngineAPI","active":true},{"api":"tma","active":true},{"api":"sre","active":true},{"api":"esbHealthCheckAPI","active":true}]}
复制代码
|
|