Replacing values inside a file.

Good day guys,

I'm having trouble in creating a logic when it comes to replacing the values inside a file.
I tried using sed command but it just doesn't work the way I want it to be.

Here is what I'm trying to achieve.

If my input file contains the values below.

NAME++GUEST1  ++GUESS2++ 

And I want to replace "GUEST1 " with "GUEST" without changing the number of characters placed on that field. Meaning if the segment has 10 characters, it will still remain 10 characters regardless of the value placed.

Is this possible?

Thank you so much in advance for any tips and recommendations.

Yes, of course it is possible.

HINT: Regular Expressions and just about any scripting language available on a Unix or Linux system.

You can't "replace "GUEST1 " with "GUEST" without changing the number of characters" without using some filler character which you need to define. While there might be a tricky method out there, sed is not good at calculating the necessary char count. Try with e.g. awk or perl .

All the OP appears to want to do is replace GUEST1 with GUEST with a space after it.

Seems trivial even without a REGEX.