sed replace line with capture groups

后端 未结 2 1466
甜味超标
甜味超标 2021-01-13 12:33

Is it possible with sed to replace a line with capture groups from the regex?

I have this regex, please note that this is fixed, I cannot change it.

si

2条回答
  •  醉话见心
    2021-01-13 13:05

    Perl to the rescue!

    perl -ne 'if (/(.*)simple sample (.*) with (.*)/) {
                print "$1$2\n";
              } else { print }'
    

提交回复
热议问题