UNIX shell script and escaping quotes for AWK script

前端 未结 3 1027
情书的邮戳
情书的邮戳 2021-01-28 04:23

I have a UNIX script that has nawk block inside it (This is just a part of the UNIX and NAWK script. It has many more logic and the below code should definitely be in nawk) This

3条回答
  •  感情败类
    2021-01-28 05:05

    If this code appears in a shell script in this form, you need to escape the single quote with a backslash so that it doesn't terminate the nawk code. Something like:

    COUNTRY_NAME = "COTE D\'IVOIRE"
    

    In the parenthesis case, you need to escape it in the string so that nawk doesn't see it as a regexp grouping operator:

    COUNTRY_NAME = "CONGO, Democratic Republic of \\(was Zaire\\)"
    

提交回复
热议问题