sed first match code example
Example 1: sed replace first in file
sed '0,/REPLACESTHIS/s//WITHTHAT/' myfile.txt
Example 2: sed up to first match
sed '/[match]/q' file.txt
#Include q option at the end to grep untilmatch only
sed '0,/REPLACESTHIS/s//WITHTHAT/' myfile.txt
sed '/[match]/q' file.txt
#Include q option at the end to grep untilmatch only