Difference between single and double quotes in awk

后端 未结 3 1450
灰色年华
灰色年华 2020-12-05 16:39

I have this awk statement:

glb_library=\"my_library\"
awk \"
        /^Direct Dependers of/ { next }
        /^---/                 { next }
            


        
3条回答
  •  -上瘾入骨i
    2020-12-05 17:24

    Never enclose any script in double quotes or you're sentencing yourself to backslash-hell. This is the syntax for what you're trying to do:

    glb_library="my_library"
    awk -v glb_library="$glb_library" '
            /^Direct Dependers of/ { next }
            /^---/                 { next }
            $0 ~ "^"glb_library":" { ver=$0; next }
                                   { gsub(/[[:space:]]/, ""); print ver":"$0 }
          ' file
    

提交回复
热议问题