hey guys, i have been trying to work this thing out with sed with no luck
i m looking for a way to replace only the first occurrence after a match
for example :
Cat
Realized what you gotta do
Dog
Realized what you gotta do
Sheep
Realized what you gotta do
Wolf
Realized what you gotta do
i would like to replace the first occurrence of "you" to "us" only if the word "Sheep" appeared somewhere erailer (could be a random number of lines befor or as a part of a sentence).
so results for this thing will be :
Cat
Realized what you gotta do
Dog
Realized what you gotta do
Sheep
Realized what us gotta do
Wolf
Realized what you gotta do
Realized what you gotta do
Dog
Realized what you gotta do
Sheep
Realized what us gotta do
Wolf
Realized what you gotta do
Sheep
Realized what you gotta do
$ awk '!f && s{print newline;f=1} /Sheep/{s=1}1' newline="its my new line" file
Realized what you gotta do
Dog
Realized what you gotta do
Sheep
its my new line
Realized what you gotta do
Wolf
Realized what you gotta do