sed error “Invalid range end”

前端 未结 1 1117
轻奢々
轻奢々 2020-12-10 15:07

I run this substitution command on Ubuntu 12.04.

$ sed -e \"s/([a-zA-Z0-9.-/\\\\ :]+)/\\1/g\"

However, the following error is raised.

相关标签:
1条回答
  • 2020-12-10 15:39

    You can solve it in two ways. One of them is to use -r switch to avoid escaping special characters and move - in the range to first or last position and avoid its special meaning, it would be like:

    sed -re "s/([a-zA-Z0-9./\\ :-]+)/\1/g"
    

    Otherwise you will need to escape either (, ) and +, like:

    sed -e "s/\([a-zA-Z0-9./\\ :-]\+\)/\1/g"
    
    0 讨论(0)
提交回复
热议问题