I have two strings :

string1: platform1-05_02_00.001:platform
string2: platform1-domino-05_02_00.001:platform

in the first one, the version (05_02_00.001) is to be changed, at first I tried the regular expression:

sed -i 's/platform1-.*:platform/platform1-06:hybrisb/g' file

but it changes the 2 strings. That's why i'm looking for some regex to tell the sed to look for the string where the isn't "domino" (not containing domino)

  • If any of the existing answers solves your problem, please consider accepting it via the checkmark. Thank you!
    – Jeff Schaller
    Apr 23, 2017 at 12:56

2 Answers 2


One way to do it:

sed '/domino/! s/platform1-.*:platform/platform1-06:hybrisb/g' file

/domino/! selects lines that don't match domino.

  • this solution works only if the the 2 strings were on seperate lines which is not my case Apr 3, 2017 at 7:41
  • @mohamedwaelthabet You might find it less embarrassing to try out your claim before posting. Apr 3, 2017 at 9:27

Consider skipping lines that contain "platform-domino" with the n command:

sed '/platform1-domino/ n; s/platform1-.*:platform/platform1-06:hybrisb/g' file

Or, search and replace, but eliminating the letters as possibilities for the match:

sed 's/platform1-[^d][^o][^m][^i][^n][^o].*:platform/platform1-06:hybrisb/g' file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.