sed gives me ": unexpected EOF (pending }'s) error and I have no idea why

后端 未结 1 1809
误落风尘
误落风尘 2020-12-02 01:21

I\'m trying to port a GNU sed command to BSD sed (in OSX). The command is:

cat -- \"$1\" | sed -n -e \"\\${/^#/H;x;/${         


        
相关标签:
1条回答
  • 2020-12-02 01:46

    Try using newlines instead of a semicolons, at least before the branch commands (b) in the statements. See if this works:

    sed -n "
      \${
        /^#/H
        x
        /${tapPrintTapOutputSedPattern}/p
      }
      /${tapPrintTapOutputSedPattern}/{
        x
        /${tapPrintTapOutputSedPattern}/p
        b
      }
      /^#/{
        H
        b
      }
      x
      /${tapPrintTapOutputSedPattern}/p
      /^Bail out!/q
    " "$1"
    
    0 讨论(0)
提交回复
热议问题