I am trying to use the syntax 1,addr2 in sed as follows: -e "1,/^create/ s/ xxx/ yyy/g" My purpose is to replace all the words "xxx" with the words "yyy" from line 1 to the line that starts with "create". It just does not work. IT works when I replace addr2 ( /^create/ ) with some number like 10. But the fact is the addr2 varies. Thanks for your advice, Vu