开发者

Deleting all characters except selected one

开发者 https://www.devze.com 2023-02-18 06:44 出处:网络
I have lines a开发者_如何学JAVAs this ATOM21001O WAT3457.55635.95437.4640.000.00 ATOM21002H1 WAT3457.07635.70136.6750.000.00

I have lines a开发者_如何学JAVAs this

ATOM  21001    O WAT   345       7.556  35.954  37.464  0.00  0.00
ATOM  21002   H1 WAT   345       7.076  35.701  36.675  0.00  0.00
ATOM  21003   H2 WAT   345       7.155  35.440  38.164  0.00  0.00
TER       0              0       0.000   0.000   0.000  0.00  0.00
ATOM  21004    O WAT   346       1.183  42.629  26.928  0.00  0.00
ATOM  21005   H1 WAT   346       1.412  43.325  26.313  0.00  0.00
ATOM  21006   H2 WAT   346       1.454  41.823  26.490  0.00  0.00
TER       0              0       0.000   0.000   0.000  0.00  0.00
ATOM  21007    O WAT   347       7.166  53.716  22.860  0.00  0.00
ATOM  21008   H1 WAT   347       7.950  54.234  22.675  0.00  0.00
ATOM  21009   H2 WAT   347       6.855  54.045  23.704  0.00  0.00
TER       0              0       0.000   0.000   0.000  0.00  0.00
ATOM  21010    O WAT   348       9.342  45.695  11.193  0.00  0.00
ATOM  21011   H1 WAT   348       8.488  45.846  10.788  0.00  0.00
ATOM  21012   H2 WAT   348       9.973  45.870  10.494  0.00  0.00
TER       0              0       0.000   0.000   0.000  0.00  0.00
ATOM  21013    O WAT   349      18.303  47.277  18.814  0.00  0.00
ATOM  21014   H1 WAT   349      17.411  47.357  18.476  0.00  0.00
ATOM  21015   H2 WAT   349      18.862  47.407  18.047  0.00  0.00

I want to delete all the characters in line contains TER except the TER word.

I have searched Internet for sed command which can do this but i can not find one which matching specific word.

Could anyone help?


You need to use the following:

sed 's/^TER.*$/TER/'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号