How do i replace [] brackets using SED

后端 未结 5 1700
予麋鹿
予麋鹿 2021-01-04 03:04

I have a string that i am want to remove punctuation from.

I started with

sed \'s/[[:punct:]]/ /g\'

But i had problems on HP-UX n

5条回答
  •  耶瑟儿~
    2021-01-04 03:45

    You can do it manually:

    sed 's/[][\/$*.^|@#{}~&()_:;%+"='\'',`>

    This remove the 32 punctuation character, the order of some characters is important:

    • - should be at the end like this -]
    • [] should be like that [][other characters]
    • ' should be escaped like that '\''
    • not begin with ^ like in [^
    • not begin with [. [= [: and end with .] =] :]
    • not end with $]

    here you can have explication of why all that http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_03

提交回复
热议问题