UNIX shell script and escaping quotes for AWK script

前端 未结 3 1022
情书的邮戳
情书的邮戳 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:19

    Obviously an issue with quoting. Pass the value to nawk using the -v option.

    Instead of

    nawk '{
            COUNTRY_NAME = "COTE D'IVOIRE"
            if (COUNTRY_NAME != " "){ ...
    

    Use

    nawk -v "COUNTRY_NAME=COTE D'IVOIRE" '{
            if (COUNTRY_NAME != " "){ ...
    

提交回复
热议问题