sed command to get 1st occrance of string in file code example Example: sed replace first in file sed '0,/REPLACESTHIS/s//WITHTHAT/' myfile.txt