Sed instance memo

Source: Internet
Author: User

Sed instance memo requirement: Modify build config file under all automation script directories. Each feature contains at least one build config file, with the file name: build. cfg, build_6.9.cfg... you need to search for the Keyword: INCLUDE_PING or INCLUDE_PING6 in each build config file. if the keyword is found, you need to insert: INCLUDE_IPPING_CMD or INCLUDE_IPPING6_CMD. There may be four types of keywords: 1. but not the end: vip_components_t1 = "INCLUDE_PING \ in this case, you need to insert the target row to the line below the keyword line. Target effect: vip_components_t1 =" INCLUDE_PING \ INCLUDE_IPPING_CMD \ 2. middle, non-starting and non-ending: vip_components_t2 = "INCLUDE_SHELL \ INCLUDE_SHELL _ INTERP_CMD \ shortde_ping \ shortde_ping6 \ shortde_ipping6_cmd "in this case, you need to add the target row to the top or top of the keyword. Target effect: vip_components_t2 = "INCLUDE_SHELL \ INCLUDE_SHELL_INTERP_CMD \ INCLUDE_PING \ INCLUDE_IPPING_CMD \ INCLUDE_PING6 \ INCLUDE_IPPING6_CMD \ Terminal" 3. Vip_components_t2 = "INCLUDE_SHELL \ INCLUDE_SHELL_INTERP_CMD \ INCLUDE_PING" in this case, you need to add the target row to the previous line of the keyword row. Target effect: vip_components_t2 = "INCLUDE_SHELL \ INCLUDE_SHELL_INTERP_CMD \ INCLUDE_IPPING_CMD \ INCLUDE_PING" 4. vip_components_t2 = "INCLUDE_PING" is a little complicated. You need to insert the target row to the bottom of the keyword line, and replace the double quotation marks after the keyword with the backslash. Target effect: vip_components_t2 = "INCLUDE_PING \ INCLUDE_IPPING_CMD" solution: After the analysis, the actual situation 1 and 2 can be solved using a sed expression, and Case 3 requires another expression. Because case 4 is rare and a little complicated, sed is not used to solve the problem (keep thinking later). sed expression: find. -name "build *. cfg "| xargs sed-e '/INCLUDE_PING \> \ s * \/a \ INCLUDE_IPPING_CMD \'-E'/INCLUDE_PING6 \> \ s * \/\ INCLUDE_IPPING6_CMD \ '-E'/[^ \ "] \ s * INCLUDE_PING \> \ s * \"/I \ INCLUDE_IPPING_CMD \'-E'/[^ \ "] \ s * INCLUDE_PING6 \> \ s * \"/I \ INCLUDE_IPPING6_CMD \ '-I this expression solves situation 1, 2, 3. To solve the problem 4: find. -name "build *. cfg "| xargs grep-niHr \" INCLUDE_PING \ "Then manually modify the files based on the searched file names (stupid method ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.