我有一個低於設定在一個文件中的行,我想插入新行與行的相同內容的輸出後,但代替uat_reset_fwd_outputs
應該Test_sample_data
如何在下一行插入模式匹配的行?
[serverClass:UAT_SAI_Forwarder:app:uat_sai_inputs]
[serverClass:UAT_SAI_Forwarder:app:uat_reset_fwd_outputs]
[serverClass:UAT_TEST_Forwarder:app:uat_test_inputs]
[serverClass:UAT_TEST_Forwarder:app:uat_reset_fwd_outputs]
The output should look like below:
[serverClass:UAT_SAI_Forwarder:app:uat_sai_inputs]
[serverClass:UAT_SAI_Forwarder:app:uat_reset_fwd_outputs]
[serverClass:UAT_SAI_Forwarder:app:Test_sample_data]
[serverClass:UAT_TEST_Forwarder:app:uat_test_inputs]
[serverClass:UAT_TEST_Forwarder:app:uat_reset_fwd_outputs]
[serverClass:UAT_TEST_Forwarder:app:Test_sample_data]
這是替換字符串匹配模式「輸出」到Test_sample_data」但我需要的。輸出應附加在匹配模式的下一行 輸出應如下所示: [serverClass:UAT_TEST_Forwarder:app:uat_test_inputs] [serverClass:UAT_TEST_Forwa rder:app:uat_reset_fwd_outputs] [serverClass:UAT_TEST_Forwarder:app:Test_sample_data] – Sai
它不會替換輸出行。在它後面添加一條新的線。這就是'\ 0 \ n \ 1'所做的。你嘗試過運行我的命令嗎? – dogbane
是的,我沒有嘗試和輸出如下: sed's /\(^.*\):.* outputs。* $/\ 0 \ n \ 1:Test_sample_data]/g'pesting [serverClass :UAT_SAI_Forwarder:應用:uat_sai_inputs] 0N [serverClass:UAT_SAI_Forwarder:應用:Test_sample_data] [serverClass:UAT_TEST_Forwarder:應用:uat_test_inputs] 0N [serverClass:UAT_TEST_Forwarder:應用:Test_sample_data] – Sai