How to remove CTRL-A characters from file using SED?

前端 未结 2 1581
情深已故
情深已故 2021-01-12 06:10

I want to remove all \"^A\" control characters from a file using SED. I can remove all control characters using \'sed s/[[:cntrl:]]//g\' but how can I specify \"^A\" specif

2条回答
  •  孤独总比滥情好
    2021-01-12 06:56

    ^A is byte 1 or \x01 so you should be able to do this:

    sed 's/\x01//g'
    

    Keep in mind that for single-byte changes, "tr" is faster than sed, although you'll have to use bash's $'..' syntax to give it a 0x01 byte:

    tr -d $'\x01'
    

提交回复
热议问题