I'm trying to use sed to find matching string on a line in a file on nth match. I want to use expression to mach num and "anything" after on that line and replace it with num x.
example file:
START num 1 num 1 num 1 num n END sed ':a;N;$!ba; s/num .*/num x/1' example outputs:
START num x sed ':a;N;$!ba; s/num 1/num x/1' example outputs:
START num x num 1 num 1 num n END Im tyring to use the .* expression to match anything after num and replace it with num x but my result leaves the end of the file out. Replacing the .* expression with the actual full string on that line gives the desired result, but it must be possible that there is "anything" following characters on that line.