-1

I am looking to use the sed command to replace a substring value.

I have a file like this

UNIT56712423MP000000R0990

The records in this file are always of the same length.

I need to check if the 21st character is R, then replace characters 13-14 from MP to GH.

Is there a way I can achieve this through the sed command?

Thanks for your help.

jas
  • 10,715
  • 2
  • 30
  • 41

1 Answers1

0

tried on gnu sed

sed -E '/^\w{20}R\w{4}$/s/^(.{12})../\1GH/' <<<UNIT56712423MP000000R0990