I would like to use sed to replace one occurence of a pattern in a file. When I use the s/// command it replaces all occurences of the pattern in the file. Should I be using something other than sed?
Thanks
One possibility with awk:
awk '/ReplaceWhat/ && !f{sub("ReplaceWhat", "ReplaceWith");f=1}{print}' file
Regards
Are you interested in the first or a particular instance of that pattern. Show an example of the input and output data.
I am interested in the first instance of the pattern.
example : I want to replace "90 rotate" with "270 rotate"
Have you tried my solution?
awk '/90 rotate/ && !f{sub("90 rotate", "270 rotate");f=1}{print}' file
how do the quotes work if I want to put it in a system() command?
I got it to work thanks